当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::getDefinition方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Application::getDefinition方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getDefinition方法的具体用法?PHP Application::getDefinition怎么用?PHP Application::getDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Application的用法示例。


在下文中一共展示了Application::getDefinition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mergeApplicationDefinition

 /**
  * @param array $definition
  * @return array
  */
 private function mergeApplicationDefinition(array $definition)
 {
     array_splice($definition, 0, 0, $this->generatorDefinition);
     if ($this->application) {
         $appDefinition = $this->application->getDefinition();
         array_splice($definition, 0, 0, $appDefinition->getArguments());
         array_splice($definition, 0, 0, $appDefinition->getOptions());
     }
     return $definition;
 }
开发者ID:tweedegolf,项目名称:generator,代码行数:14,代码来源:CommandInputResolver.php

示例2: __construct

 /**
  * Constructor.
  * 
  * @param AbstractApplication $pplication Application to which this console belongs.
  */
 public function __construct(AbstractApplication $application, LoggerInterface $logger = null)
 {
     $this->application = $application;
     $this->logger = $logger;
     // initialize Symfony Console component
     $this->consoleApplication = new ConsoleApplication($application->getName() . ' (Splot Console)', $application->getVersion());
     $definition = $this->consoleApplication->getDefinition();
     $definition->addOption(new InputOption('env', null, InputOption::VALUE_REQUIRED, 'Environment in which to run.'));
     $definition->addOption(new InputOption('no-debug', null, InputOption::VALUE_NONE, 'Turn off debug mode.'));
     // now gather all commands from the application
     foreach ($this->application->getModules() as $module) {
         $this->readModuleCommands($module);
     }
 }
开发者ID:splot,项目名称:framework,代码行数:19,代码来源:Console.php

示例3: getAllOptions

 /**
  * Get the combined options of the application and entered command
  *
  * @return InputOption[]
  */
 protected function getAllOptions()
 {
     if (!$this->command) {
         return $this->application->getDefinition()->getOptions();
     }
     return array_merge($this->command->getNativeDefinition()->getOptions(), $this->application->getDefinition()->getOptions());
 }
开发者ID:stecman,项目名称:symfony-console-completion,代码行数:12,代码来源:CompletionHandler.php

示例4: getDefinition

 /**
  * {@inheritdoc}
  *
  * Overridden so the application doesn't expect the command name as the first
  * argument.
  */
 public function getDefinition()
 {
     $definition = parent::getDefinition();
     // Clears the normal first argument (the command name).
     $definition->setArguments();
     return $definition;
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:13,代码来源:GenerateProxyClassApplication.php

示例5: getDefinition

 /**
  * @inheritDoc
  */
 public function getDefinition()
 {
     $inputDefinition = parent::getDefinition();
     // remove command name from arguments
     $inputDefinition->setArguments();
     return $inputDefinition;
 }
开发者ID:natebrunette,项目名称:pd,代码行数:10,代码来源:PdApplication.php

示例6: getDefinition

 /**
  * {@inheritDoc}
  */
 public function getDefinition()
 {
     $inputDefinition = parent::getDefinition();
     // clear out the normal first argument, which is the command name
     $inputDefinition->setArguments();
     return $inputDefinition;
 }
开发者ID:ifa6,项目名称:elk-monolog-example,代码行数:10,代码来源:Application.php

示例7: run

 public static function run()
 {
     // Create the instance
     $app = new ConsoleApp();
     $app->setName(self::NAME);
     $app->setVersion(self::VERSION);
     // Remove default options. We only keep help & version.
     $options = $app->getDefinition()->getOptions();
     $options = [$options['version'], $options['help']];
     $app->getDefinition()->setOptions($options);
     // TODO: Use a more comfortable way to handle included commands (configuration file / autoload / whatever)
     // Add some commands
     $app->add(new Main());
     // Lets go...
     $app->run();
 }
开发者ID:mrccnt,项目名称:phar-skeleton,代码行数:16,代码来源:Application.php

示例8: register

 /**
  * Registers services on the given container.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param \Pimple\Container $container A container instance
  */
 public function register(Container $container)
 {
     $container['console.name'] = 'Console';
     $container['console.version'] = '1.0';
     $container['console.event_dispatcher'] = null;
     $container['console.enable_xdebug'] = false;
     $container['console'] = function (Container $container) {
         $console = new ConsoleApplication($container['console.name'], $container['console.version']);
         if ($container['console.enable_xdebug'] && function_exists('xdebug_enable')) {
             $definition = $console->getDefinition();
             $definition->addOption(new InputOption('debug', null, InputOption::VALUE_NONE, 'Enable XDebug jit remote mode'));
             $console->setDefinition($definition);
             foreach ($_SERVER['argv'] as $arg) {
                 if ('--debug' === $arg) {
                     poke_xdebug();
                     break;
                 } elseif ('--' === $arg) {
                     break;
                 }
             }
         }
         $dispatcher = $container['console.event_dispatcher'];
         if (is_string($dispatcher)) {
             $dispatcher = $container[$dispatcher];
         }
         if ($dispatcher instanceof EventDispatcherInterface) {
             $console->setDispatcher($dispatcher);
             $dispatcher->dispatch(Events::INIT, new InitializeConsoleEvent($console));
         }
         return $console;
     };
 }
开发者ID:jonsa,项目名称:pimple-console,代码行数:40,代码来源:ServiceProvider.php

示例9: getDefinition

 /**
  * Surchargé afin que l'application accepte que le premier argument ne
  * soit pas le nom.
  */
 public function getDefinition()
 {
     $inputDefinition = parent::getDefinition();
     // efface le premier argument, qui est le nom de la commande
     $inputDefinition->setArguments();
     return $inputDefinition;
 }
开发者ID:srobfr,项目名称:trashman,代码行数:11,代码来源:TrashmanApplication.php

示例10: getDefinition

 /**
  * @return InputDefinition
  */
 public function getDefinition()
 {
     $inputDefinition = parent::getDefinition();
     if (null !== $this->commandName) {
         $inputDefinition->setArguments();
     }
     return $inputDefinition;
 }
开发者ID:picur,项目名称:microservice-lib,代码行数:11,代码来源:Application.php

示例11: initHelper

 /**
  * @param Application $application
  * @param mixed $default
  * @param array $options
  * @return ConfigurationHelper
  */
 public static function initHelper(Application $application, $default = null, array $options = [])
 {
     $options = $options + ['name' => 'config', 'abbreviation' => 'c', 'description' => 'Path to the configuration file.', 'filename' => 'cli-config.php'];
     $helper = new static($options['name'], $options['filename']);
     $helper->setDefault($default);
     $application->getDefinition()->addOption(new InputOption($options['name'], $options['abbreviation'], InputOption::VALUE_REQUIRED, $options['description']));
     $application->getHelperSet()->set($helper);
     return $helper;
 }
开发者ID:phlib,项目名称:console-configuration,代码行数:15,代码来源:ConfigurationHelper.php

示例12: getDefinition

 /**
  * {@inheritdoc}
  */
 public function getDefinition()
 {
     $inputDefinition = parent::getDefinition();
     $inputDefinition->setArguments();
     $inputDefinition->addOption(new InputOption('config', 'c', InputOption::VALUE_REQUIRED, 'Path to the configuration file'));
     $inputDefinition->addOption(new InputOption('log', 'l', InputOption::VALUE_REQUIRED, 'Log into a file'));
     $inputDefinition->addOption(new InputOption('log-level', 'L', InputOption::VALUE_REQUIRED, 'The log level (emergency, alert, critical, error, warning, notice, info, debug)', 'info'));
     return $inputDefinition;
 }
开发者ID:contao-community-alliance,项目名称:build-system-repositories,代码行数:12,代码来源:Application.php

示例13: getDefinition

 public function getDefinition()
 {
     if (method_exists('Symfony\\Component\\Console\\Application', 'getDefaultCommands')) {
         return parent::getDefinition();
     } else {
         // For compatibility with Symfony 2.0
         static $definition;
         if (is_null($definition)) {
             $definition = $this->getDefaultInputDefinition();
         }
         return $definition;
     }
 }
开发者ID:rsky,项目名称:stagehand-testrunner,代码行数:13,代码来源:Application.php

示例14: setupApplication

 /**
  * @param Container $container
  */
 private function setupApplication(Container $container)
 {
     $this->addMany($container, ['application.ucd' => function (Container $container) {
         $application = new Application('Unicode Character Database', PHPUCD_VERSION);
         $application->add($container['command.repository_transfer']);
         $application->add($container['command.search']);
         $application->add($container['command.props']);
         $definition = $application->getDefinition();
         $option = new InputOption('config', 'c', InputOption::VALUE_OPTIONAL, 'Configuration file', null);
         $definition->addOption($option);
         return $application;
     }]);
 }
开发者ID:nick-jones,项目名称:php-ucd,代码行数:16,代码来源:ApplicationServiceProvider.php

示例15: describeApplication

 /**
  * {@inheritdoc}
  */
 protected function describeApplication(Application $application, array $options = [])
 {
     $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
     $description = new ApplicationDescription($application, $describedNamespace);
     if (isset($options['raw_text']) && $options['raw_text']) {
         $width = $this->getColumnWidth($description->getCommands());
         foreach ($description->getCommands() as $command) {
             $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
             $this->writeText("\n");
         }
     } else {
         if ('' != ($help = $application->getHelp())) {
             $this->writeText("{$help}\n\n", $options);
         }
         $this->writeText("<comment>Usage:</comment>\n", $options);
         $this->writeText("  command [options] [arguments]\n\n", $options);
         $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
         $this->writeText("\n");
         $this->writeText("\n");
         $width = $this->getColumnWidth($description->getCommands());
         if ($describedNamespace) {
             $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
         } else {
             $this->writeText('<comment>Available commands:</comment>', $options);
         }
         // add commands by namespace
         foreach ($description->getNamespaces() as $namespace) {
             if ($this->shouldListCommand($namespace['id']) === false) {
                 continue;
             }
             if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
                 $this->writeText("\n");
                 $this->writeText(' <comment>' . $namespace['id'] . '</comment>', $options);
             }
             foreach ($namespace['commands'] as $name) {
                 if ($this->shouldListCommand($namespace['id'], $name) === false) {
                     continue;
                 }
                 $this->writeText("\n");
                 $spacingWidth = $width - strlen($name);
                 $this->writeText(sprintf('  <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
             }
         }
         $this->writeText("\n");
     }
 }
开发者ID:codex-project,项目名称:develop,代码行数:49,代码来源:TextDescriptor.php


注:本文中的Symfony\Component\Console\Application::getDefinition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。