Skip to content

Instantly share code, notes, and snippets.

@makasim
Created June 8, 2011 10:57
Show Gist options
  • Save makasim/1014202 to your computer and use it in GitHub Desktop.
Save makasim/1014202 to your computer and use it in GitHub Desktop.
Symfony2 Command and logging
protected function execute(InputInterface $input, OutputInterface $output)
{
$fixtureDir = \APPLICATION_PATH . '/' . $input->getArgument('dir');
if (!\is_dir($fixtureDir)) {
throw new \Exception('The fixture dir `'.$fixtureDir.'` is not exist.');
}
$loader = new Loader();
$loader->loadFromDirectory($fixtureDir);
$executor = new ORMExecutor(\Zend_Registry::get('em'), new ORMPurger());
$executor->setLogger(function($msg) use ($output) {
$output->writeln($msg);
});
$executor->execute($loader->getFixtures());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment