コード例 #1
0
 /**
  * @param $command
  * @return array
  */
 private function getCommandAliases($command)
 {
     $aliasKey = sprintf('application.aliases.commands.%s', str_replace(':', '.', $command->getName()));
     return $this->config->get($aliasKey);
 }
コード例 #2
0
ファイル: Application.php プロジェクト: GoZOo/DrupalConsole
 /**
  * {@inheritdoc}
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $root = null;
     $config = $this->getConfig();
     $target = $input->getParameterOption(['--target'], null);
     if ($input) {
         $commandName = $this->getCommandName($input);
     }
     $targetConfig = [];
     if ($target && $config->loadTarget($target)) {
         $targetConfig = $config->getTarget($target);
         $root = $targetConfig['root'];
     }
     if ($targetConfig && $targetConfig['remote']) {
         $remoteHelper = $this->getRemoteHelper();
         $remoteResult = $remoteHelper->executeCommand($commandName, $target, $targetConfig, $input->__toString(), $config->getUserHomeDir());
         $output->writeln($remoteResult);
         return 0;
     }
     if (!$target) {
         $root = $input->getParameterOption(['--root'], null);
     }
     $env = $input->getParameterOption(array('--env', '-e'), getenv('DRUPAL_ENV') ?: 'prod');
     $debug = getenv('DRUPAL_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
     $message = $this->getMessageHelper();
     $drupal = $this->getDrupalHelper();
     $site = $this->getSite();
     $commandDiscovery = $this->getCommandDiscoveryHelper();
     $commandDiscovery->setApplicationRoot($this->getDirectoryRoot());
     $recursive = false;
     if (!$root) {
         $root = getcwd();
         $recursive = true;
     }
     if (!$drupal->isValidRoot($root, $recursive)) {
         $commands = $commandDiscovery->getConsoleCommands();
         if (!$commandName) {
             $message->addWarningMessage($this->trans('application.site.errors.directory'));
         }
     } else {
         chdir($drupal->getRoot());
         $site->setSitePath($drupal->getRoot());
         if ($drupal->isValidInstance()) {
             $this->bootDrupal($env, $debug, $drupal);
         }
         if ($drupal->isInstalled()) {
             $disabledModules = $this->config->get('application.disable.modules');
             $commandDiscovery->setDisabledModules($disabledModules);
             $commands = $commandDiscovery->getCommands();
         } else {
             $commands = $commandDiscovery->getConsoleCommands();
             if (!$commandName) {
                 $message->addWarningMessage($this->trans('application.site.errors.settings'));
             }
         }
     }
     $this->registerCommands($commands, $drupal);
     if (true === $input->hasParameterOption(['--shell', '-s'])) {
         $this->runShell($input);
         return;
     }
     if (true === $input->hasParameterOption(array('--generate-doc', '--gd'))) {
         $command = $this->get($commandName);
         $command->addOption('generate-doc', '--gd', InputOption::VALUE_NONE, $this->trans('application.console.arguments.generate-doc'));
     }
     parent::doRun($input, $output);
 }