當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Application::setDefinition方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Application::setDefinition方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::setDefinition方法的具體用法?PHP Application::setDefinition怎麽用?PHP Application::setDefinition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Application的用法示例。


在下文中一共展示了Application::setDefinition方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: testSettingCustomInputDefinitionOverwritesDefaultValues

 public function testSettingCustomInputDefinitionOverwritesDefaultValues()
 {
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->setDefinition(new InputDefinition(array(new InputOption('--custom', '-c', InputOption::VALUE_NONE, 'Set the custom input definition.'))));
     $inputDefinition = $application->getDefinition();
     // check whether the default arguments and options are not returned any more
     $this->assertFalse($inputDefinition->hasArgument('command'));
     $this->assertFalse($inputDefinition->hasOption('help'));
     $this->assertFalse($inputDefinition->hasOption('quiet'));
     $this->assertFalse($inputDefinition->hasOption('verbose'));
     $this->assertFalse($inputDefinition->hasOption('version'));
     $this->assertFalse($inputDefinition->hasOption('ansi'));
     $this->assertFalse($inputDefinition->hasOption('no-ansi'));
     $this->assertFalse($inputDefinition->hasOption('no-interaction'));
     $this->assertTrue($inputDefinition->hasOption('custom'));
 }
開發者ID:Ener-Getick,項目名稱:symfony,代碼行數:18,代碼來源:ApplicationTest.php


注:本文中的Symfony\Component\Console\Application::setDefinition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。