<?php
namespace AppBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class PublishAdCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('app:publish:ad')
            ->setDescription('Publish or unpublish Ad.')
            ->setHelp('This command allows you to publish or unpublish ad according to their publish date.');
    }

    /**
     * @param InputInterface $input
     * @param OutputInterface $output
     *
     * This command permit to launch AD publishing which check status and date of ads
     * in order to publish or unpublish them
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $style = new OutputFormatterStyle('red', 'yellow', array('bold', 'blink'));
        $output->getFormatter()->setStyle('fire', $style);
        $output->writeln([
            'Publish AD',
            '============',
            '',
        ]);
        $output->writeln('Chuck is in da place');
        $output->writeln('Executing publish AD script');
        $adManager = $this->getContainer()->get('app.ad_manager');
        $adManager->publishAd($output);
    }
}