<?php

namespace OfficeBrain\Bundle\EmailBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use OfficeBrain\Bundle\UserBundle\Entity\User;

/**
 * Roaster Migration command
 *
 * @author OfficeBrain 4071 <info@officebrain.com>
 */
class EmailCronCommand extends ContainerAwareCommand
{
        CONST COMMAND_NAME = 'office_brain_email:cron:email';
    CONST TUBE_PREFIX = 'email_';
    CONST PAGING_LIMIT = 10;
    /**
     * {@inheritdoc}
     */
     
    protected function configure()
    {
        $this
            ->setName(self::COMMAND_NAME)
            ->setDescription('Command to sync roaster data')
            ->addOption('importSection', null, InputOption::VALUE_REQUIRED, 'importSection', '')
            ->setHelp(<<<EOT
The <info>office_brain_email:cron:email</info> Migration Script For Wordpress Roaster To Symfony Roaster:
        
  <info>php app/console office_brain_email:cron:email --importSection="---"</info>
  <info>Note: Perform migration with given sequence - 1."record_info" 2."company_owner" 3."contact_info" 4."branch" 5."voting_member" 6."employees" 7."contact_member"
                    8."ml_agencies" 9."primary_products" 10."ss_policies" 11."oc_info" </info>
EOT
                    );
    }
    
    public function init()
    {
        $this->emailServiceManager = $this->getContainer()->get('office_brain_email_service');
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->init();
        $importSection = $input->getOption('importSection');
        
        if($importSection == 'record_info'){
            $this->migrationRecordInfo($input, $output);
        } else {
            $this->emailServiceManager->releaseEmails();
            $output->writeln("sucess");
        }
        
    }
    
   
}