J'ai besoin d'un travail cron pour mon site symfony. J'ai trouvé tutoriel pour créer la commande de la console dans http://symfony.com/doc/2.1/cookbook/console/console_command.htmlGestionnaire de document dans symfony2 dans la console de commande
Mon espace de noms command.php
xxx \ WebBundle \ Command;
utilisez Symfony \ Component \ Console \ Command \ Command; utilisez Symfony \ Component \ Console \ Input \ InputArgument; utilisez Symfony \ Component \ Console \ Input \ InputInterface; utilisez Symfony \ Component \ Console \ Input \ InputOption; utilisez Symfony \ Component \ Console \ Output \ OutputInterface;
classe GreetCommand étend commande { configure la fonction protégée() {
} protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getContainer()->get('doctrine')->getManager(); $em->getRepository('xxxWebBundle:Wishlist')->findAll(); // $output->writeln($text); }
}
Quand j'appelle commande dans la console, obtenir erreur "Appel à la méthode définie xxxx \ WebBundle \ Command \ MyCommand :: getContainer() " Comment puis-je obtenir le gestionnaire de document dans la fonction d'exécution?