示例#1
0
 /**
  * @param string             $name
  * @param ContainerInterface $dic
  *
  * @throws \Symfony\Component\Console\Exception\InvalidArgumentException
  * @throws \Symfony\Component\Console\Exception\LogicException
  */
 public function __construct(string $name, ContainerInterface $dic)
 {
     $this->setDescription('Retrieves SQL from files and updates schema');
     $this->setName($name);
     $this->setDic($dic);
     parent::__construct($name);
 }
示例#2
0
 /**
  * Executes the current command.
  *
  * This method is not abstract because you can use this class
  * as a concrete class. In this case, instead of defining the
  * execute() method, you set the code to execute by passing
  * a Closure to the setCode() method.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return int null or 0 if everything went fine, or an error code
  * @throws \DomainException
  * @throws \InvalidArgumentException
  * @throws \LogicException
  * @throws \Symfony\Component\Console\Exception\InvalidArgumentException
  * @throws \Symfony\Component\Console\Exception\LogicException
  * @throws \Symfony\Component\Console\Exception\RuntimeException
  * @throws \Yapeal\Exception\YapealDatabaseException
  * @throws \Yapeal\Exception\YapealException
  *
  * @see    setCode()
  */
 protected function execute(InputInterface $input, OutputInterface $output) : int
 {
     if (!$this->hasYem()) {
         $this->setYem($this->getDic()['Yapeal.Event.Mediator']);
     }
     if ($input->getOption('dropSchema')) {
         /**
          * @var QuestionHelper $question
          */
         $question = $this->getHelper('question');
         $mess = '<comment>Are you sure you want to drop the schema(database)' . ' and it\'s tables with their data?(no)</comment>';
         $confirm = new ConfirmationQuestion($mess, false);
         $this->dropSchema = (bool) $question->ask($input, $output, $confirm);
         if (!$this->dropSchema) {
             $output->writeln('<info>Ignoring drop schema(database)</info>');
         }
     }
     return parent::execute($input, $output);
 }