Skip to content

Instantly share code, notes, and snippets.

@wowo
Created September 26, 2011 22:25
Show Gist options
  • Save wowo/1243584 to your computer and use it in GitHub Desktop.
Save wowo/1243584 to your computer and use it in GitHub Desktop.
Closure logger from Symfony2 command
<?php
class SendMailingCommand extends ContainerAwareCommand
{
protected function execute(InputInterface $input, OutputInterface $output)
{
$logger = function($message) use ($output)
{
$output->writeln($message);
};
while (1) {
$this
->getContainer()
->get('wowo_newsletter.newsletter_manager')
->getJobFromQueueAndSendMailing($logger, $input->getOption('verbose'));
}
}
}
class SendMailingCommand extends ContainerAwareCommand
{
protected function execute(InputInterface $input, OutputInterface $output)
{
$logger = function($message) use ($output)
{
$output->writeln($message);
};
while (1) {
$this->getContainer()->get('wowo_newsletter.newsletter_manager')->getJobFromQueueAndSendMailing($logger, $input->getOption('verbose'));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment