Пример #1
0
 /**
  * {@inheritdoc}
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     if (!$this->getApplication()->getConfiguration()['env-dir']) {
         throw new \Exception('Config env-dir is missing');
     }
     $dir = $this->getApplication()->getRoot() . '/' . $this->getApplication()->getConfiguration()['env-dir'];
     if (!is_dir($dir)) {
         throw new \Exception('Directory ' . $dir . ' is missing');
     }
     $environments = (include $dir . '/index.php');
     if (!is_array($environments)) {
         throw new \Exception('File with description of environments is missing');
     } elseif (count($environments) == 0) {
         throw new \Exception('Environments not found in description file');
     }
     if ($input->getArgument('type')) {
         $code = $input->getArgument('type');
         if (!isset($environments[$code])) {
             throw new \Exception('Invalid environment code!');
         }
     } else {
         foreach ($environments as $code => $environment) {
             $choices[$code] = $environment['name'];
         }
         $questionHelper = $this->getHelper('question');
         $question = new ChoiceQuestion('<info>Which environment install?</info>', $choices, false);
         $code = $questionHelper->ask($input, $output, $question);
     }
     if (!isset($environments[$code]['path'])) {
         throw new \Exception('Environment path not found!');
     }
     $this->dir = $dir . '/' . $environments[$code]['path'];
     $this->config = (include $this->dir . '/config.php');
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $this->tmplDir = __DIR__ . '/../../../tmpl';
     $this->questionHelper = $this->getHelper('question');
     parent::initialize($input, $output);
 }