Skip to content

Instantly share code, notes, and snippets.

@jmeyo
Created June 16, 2014 13:41
Show Gist options
  • Save jmeyo/ba98a69053289016058c to your computer and use it in GitHub Desktop.
Save jmeyo/ba98a69053289016058c to your computer and use it in GitHub Desktop.
Generate invoices command
<?php
namespace Example\BackBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
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 ValidateOrdersCommand extends ContainerAwareCommand {
protected function configure() {
$this
->setName('invoices:generate')
->setDescription('Generate the Invoices')
->addOption(
'month',
'd',
InputOption::VALUE_OPTIONAL,
'The month to generate invoices for',
date('Y-m')
)
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$month = $input->getOption('month');
$res = $this->getContainer()->get('some.manager')->generateInvoices($month, $after);
$output->writeln("<comment>$res</comment> <info>invoices were generated!</info>");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment