Knp\Bundle\KnpBundlesBundle\Command\KbGenerateBadgesCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $bundleRepository = $this->getContainer()->get('doctrine')->getRepository('Knp\\Bundle\\KnpBundlesBundle\\Entity\\Bundle');
        /* @var $badgeGenerator \Knp\Bundle\KnpBundlesBundle\Badge\BadgeGenerator */
        $badgeGenerator = $this->getContainer()->get('knp_bundles.badge_generator');
        $badgesCount = 0;
        /* @var $bundle \Knp\Bundle\KnpBundlesBundle\Entity\Bundle */
        foreach ($bundleRepository->findAll() as $bundle) {
            try {
                $badgeGenerator->generate($bundle);
                ++$badgesCount;
            } catch (ImageNotSavedException $e) {
                $output->writeln('<error>Error occurred during an image saving for ' . $bundle->getOwnerName() . '-' . $bundle->getName() . ' </error>');
            }
        }
        $output->writeln($badgesCount . ' badge(s) ' . ($badgesCount == 1 ? 'was' : 'were') . ' generated');
    }
KbGenerateBadgesCommand