Document manager in symfony2 in console command
I need a cron job for my symfony site. I have found tutorial to create
console command in
http://symfony.com/doc/2.1/cookbook/console/console_command.html
My command.php
namespace xxx\WebBundle\Command;
use Symfony\Component\Console\Command\Command; use
Symfony\Component\Console\Input\InputArgument; use
Symfony\Component\Console\Input\InputInterface; use
Symfony\Component\Console\Input\InputOption; use
Symfony\Component\Console\Output\OutputInterface;
class GreetCommand extends Command { protected function configure() {
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->getContainer()->get('doctrine')->getManager();
$em->getRepository('WishbotWebBundle:Wishlist')->findAll();
// $output->writeln($text);
}
}
When I call command in console, getting error " Call to undefined method
xxxx\WebBundle\Command\GreetCommand::getContainer() " How can I get the
document manger in execute function?
No comments:
Post a Comment