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


PHP Command::setApplication方法代码示例

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


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

示例1: wrapCommand

 /**
  * @param string $entityManagerName
  * @return string
  */
 protected function wrapCommand($entityManagerName)
 {
     if (!$this->isVersionCompatible()) {
         throw new \RuntimeException(sprintf('"%s" requires doctrine-orm "%s" or newer', $this->getName(), $this->getMinimalVersion()));
     }
     DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $entityManagerName);
     $this->command->setApplication($this->getApplication());
     return $this->command;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:13,代码来源:DelegateCommand.php

示例2: testConsoleEvent

 public function testConsoleEvent()
 {
     $dispatcher = new EventDispatcher();
     $listener = new DebugHandlersListener(null);
     $app = $this->getMock('Symfony\\Component\\Console\\Application');
     $app->expects($this->once())->method('getHelperSet')->will($this->returnValue(new HelperSet()));
     $command = new Command(__FUNCTION__);
     $command->setApplication($app);
     $event = new ConsoleEvent($command, new ArgvInput(), new ConsoleOutput());
     $dispatcher->addSubscriber($listener);
     $xListeners = array(KernelEvents::REQUEST => array(array($listener, 'configure')), ConsoleEvents::COMMAND => array(array($listener, 'configure')));
     $this->assertSame($xListeners, $dispatcher->getListeners());
     $exception = null;
     $eHandler = new ErrorHandler();
     set_error_handler(array($eHandler, 'handleError'));
     set_exception_handler(array($eHandler, 'handleException'));
     try {
         $dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
     } catch (\Exception $exception) {
     }
     restore_exception_handler();
     restore_error_handler();
     if (null !== $exception) {
         throw $exception;
     }
     $xHandler = $eHandler->setExceptionHandler('var_dump');
     $this->assertInstanceOf('Closure', $xHandler);
     $app->expects($this->once())->method('renderException');
     $xHandler(new \Exception());
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:30,代码来源:DebugHandlersListenerTest.php

示例3: setApplication

 /**
  * Sets the application instance for this command.
  *
  * @param Application $application
  *        	An Application instance
  *        	
  *        	@api
  */
 public function setApplication(Application $application = null)
 {
     if ($application !== null && !$application instanceof Shell) {
         throw new \InvalidArgumentException('PsySH Commands require an instance of Psy\\Shell.');
     }
     return parent::setApplication($application);
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:15,代码来源:Command.php

示例4: postInstall

 public static function postInstall(Event $event)
 {
     // Check if npm is installed
     exec('hash npm 2>/dev/null || { exit 1; }', $result, $returnVar);
     $npmInstalled = $returnVar == 0 ? true : false;
     if ($npmInstalled === true) {
         // Instantiate the Command
         $command = new Command('post-create');
         $command->setApplication(new Application());
         // Load the dialog helper
         $dialog = $command->getHelperSet()->get('dialog');
         // Write output to the console
         $output = new ConsoleOutput();
         if ($dialog->askConfirmation($output, "\n<info>Install Gulp and it's dependencies?</info> [<comment>Y,n</comment>]? ", false)) {
             // Check if npm is installed
             exec('hash gulp 2>/dev/null || { exit 1; }', $out, $returnVar);
             $gulpInstalled = $returnVar == 0 ? true : false;
             if ($gulpInstalled === false) {
                 $output->writeln("\n<info>Installing Gulp</info>\n");
                 $output->writeln("\$ sudo npm install -g gulp\n");
                 exec('sudo npm install -g gulp');
             }
             $output->writeln("\n<info>Installing dependencies</info>\n");
             $output->writeln("\$ npm install\n");
             exec('npm install');
             return;
         }
     }
 }
开发者ID:pixelfusion,项目名称:api-blueprint-parser,代码行数:29,代码来源:ComposerScripts.php

示例5: setApplication

 /**
  * Sets the application instance for this command.
  *
  * Set extra helper ProjectDir
  *
  * @param Application $application An Application instance
  * @throws \Exception
  * @api
  */
 public function setApplication(Application $application = null)
 {
     parent::setApplication($application);
     if (!$this->getHelperSet()) {
         throw new \Exception('Helper set is not set.');
     }
     $this->getHelperSet()->set(new SimpleQuestionHelper());
 }
开发者ID:andkirby,项目名称:console-helper,代码行数:17,代码来源:AbstractCommand.php

示例6: setApplication

 public function setApplication(Application $application = NULL)
 {
     parent::setApplication($application);
     $application->setAutoExit(TRUE);
     /** @var Container $container */
     $container = $this->getHelper('container')->getContainer();
     $container->callInjects($this);
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:8,代码来源:Command.php

示例7: executeCommand

 private function executeCommand(Command $command, Input $input)
 {
     $command->setApplication($this->application);
     $input->setInteractive(false);
     if ($command instanceof ContainerAwareCommand) {
         $command->setContainer($this->client->getContainer());
     }
     $command->run($input, new NullOutput());
 }
开发者ID:ajouve,项目名称:doctrine-fixtures-test,代码行数:9,代码来源:FixtureTestCase.php

示例8: executeConsole

 /**
  * @param Command  $command
  * @param string[] $arguments
  *
  * @return string
  */
 protected function executeConsole(Command $command, array $arguments = array())
 {
     $command->setApplication(new Application($this->client->getKernel()));
     if ($command instanceof ContainerAwareCommand) {
         $command->setContainer($this->client->getContainer());
     }
     $arguments = array_replace(array('--env' => 'test', 'command' => $command->getName()), $arguments);
     $commandTester = new CommandTester($command);
     $commandTester->execute($arguments);
     return $commandTester->getDisplay();
 }
开发者ID:MHaendel,项目名称:PayumBundle,代码行数:17,代码来源:CreateCaptureTokenCommandTest.php

示例9: getCommandTester

 /**
  * @param Command       $command
  * @param array|null    $systemConfig
  * @param array|null    $localConfig
  * @param \Closure|null $helperSetManipulator
  *
  * @return CommandTester
  */
 protected function getCommandTester(Command $command, array $systemConfig = null, array $localConfig = null, $helperSetManipulator = null)
 {
     if (null === $systemConfig) {
         $systemConfig = ['adapters' => ['github_enterprise' => ['authentication' => ['username' => 'cordoval', 'password' => 'very-un-secret']]]];
     }
     if (null === $localConfig) {
         $localConfig = self::$localConfig;
     }
     if ($this->requiresRealConfigDir()) {
         $config = new Config($this->getNewTmpDirectory('home'), $systemConfig, $this->getNewTmpDirectory('repo-dir'), $localConfig);
     } else {
         try {
             // Note. The paths must be invalid to always trigger the exception
             $config = new Config(':?/temp/user', $systemConfig, ':?/temp/repo-dir', $localConfig);
         } catch (IOException $e) {
             echo sprintf("Test-class \"%s\" seems to use the filesystem! \nOverwrite requiresRealConfigDir() with 'return " . "true;' to enable the Configuration filesystem usage.", get_class($this));
             throw $e;
         }
     }
     $application = $this->getApplication($config, $helperSetManipulator);
     $command->setApplication($application);
     return new CommandTester($command);
 }
开发者ID:gushphp,项目名称:gush,代码行数:31,代码来源:CommandTestCase.php

示例10: add

 /**
  * Adds a command object.
  *
  * If a command with the same name already exists, it will be overridden.
  *
  * @param Command $command A Command object
  *
  * @return Command The registered command
  *
  * @api
  */
 public function add(Command $command)
 {
     $command->setApplication($this);
     if (!$command->isEnabled()) {
         $command->setApplication(null);
         return;
     }
     if (null === $command->getDefinition()) {
         throw new \LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', get_class($command)));
     }
     $this->commands[$command->getName()] = $command;
     foreach ($command->getAliases() as $alias) {
         $this->commands[$alias] = $command;
     }
     return $command;
 }
开发者ID:astronautyan,项目名称:O2OMobile_PHP,代码行数:27,代码来源:Application.php

示例11: add

 /**
  * Adds a command object.
  *
  * If a command with the same name already exists, it will be overridden.
  *
  * @param Command $command A Command object
  *
  * @return Command The registered command
  *
  * @api
  */
 public function add(Command $command)
 {
     $command->setApplication($this);
     $this->commands[$command->getName()] = $command;
     foreach ($command->getAliases() as $alias) {
         $this->commands[$alias] = $command;
     }
     return $command;
 }
开发者ID:pollux1er,项目名称:dlawebdev2,代码行数:20,代码来源:Application.php

示例12: add

 /**
  * Adds a command object.
  *
  * If a command with the same name already exists, it will be overridden.
  *
  * @param Command $command A Command object
  *
  * @return Command The registered command
  *
  * @api
  */
 public function add(Command $command)
 {
     $command->setApplication($this);
     if (!$command->isEnabled()) {
         $command->setApplication(null);
         return;
     }
     $this->commands[$command->getName()] = $command;
     foreach ($command->getAliases() as $alias) {
         $this->commands[$alias] = $command;
     }
     return $command;
 }
开发者ID:GroupEsi,项目名称:PSE,代码行数:24,代码来源:Application.php

示例13: setApplication

 /**
  * {@inheritdoc}
  */
 public function setApplication(Application $application = null)
 {
     $this->decoratedCommand->setApplication($application);
 }
开发者ID:frankdejonge,项目名称:locked-console-command,代码行数:7,代码来源:LockedCommandDecorator.php

示例14: setApplication

 public function setApplication(Application $application = null)
 {
     parent::setApplication($application);
     $this->innerCommand->setApplication($application);
 }
开发者ID:lolautruche,项目名称:ezsh,代码行数:5,代码来源:WrappedCommand.php

示例15: runCommand

 /**
  * Run a Symfony command.
  *
  * @param Command         $command    The command to run.
  * @param array           $parameters An array of parameters to give to the command.
  * @param InputInterface  $input      An InputInterface instance
  * @param OutputInterface $output     An OutputInterface instance
  *
  * @return int The command return code.
  */
 protected function runCommand(Command $command, array $parameters, InputInterface $input, OutputInterface $output)
 {
     // add the command's name to the parameters
     array_unshift($parameters, $this->getName());
     // merge the default parameters
     $extraParameters = ['--verbose' => $input->getOption('verbose')];
     if ($command->getDefinition()->hasOption('schema-dir')) {
         $extraParameters['--schema-dir'] = $this->cacheDir;
     }
     if ($command->getDefinition()->hasOption('config-dir')) {
         $extraParameters['--config-dir'] = $this->cacheDir;
     }
     $parameters = array_merge($extraParameters, $parameters);
     if ($input->hasOption('platform')) {
         if ($platform = $input->getOption('platform') ?: $this->getPlatform()) {
             $parameters['--platform'] = $platform;
         }
     }
     $command->setApplication($this->getApplication());
     // and run the sub-command
     return $command->run(new ArrayInput($parameters), $output);
 }
开发者ID:naldz,项目名称:cyberden,代码行数:32,代码来源:AbstractCommand.php


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