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


PHP Application::add方法代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 public function execute(ContainerInterface $app)
 {
     foreach ($this->commands as $command) {
         $this->console->add($app->create($command));
     }
     $this->console->run();
 }
开发者ID:Festiv,项目名称:Festiv,代码行数:10,代码来源:ConsoleKernel.php

示例2: setUp

 public function setUp()
 {
     $config = new DummyConfig();
     $this->application = new Application();
     $this->application->add(new CliTaskCommand());
     $this->execDir = getcwd() . "/vendor/opencart";
 }
开发者ID:beyondit,项目名称:ocok,代码行数:7,代码来源:BasicInitializationTest.php

示例3: setUp

 protected function setUp()
 {
     $this->application = new Application();
     $this->application->add(new CalculatePomodorosCommand());
     $this->command = $this->application->find('pomodoro:calculate');
     $this->commandTester = new CommandTester($this->command);
 }
开发者ID:caveja,项目名称:pomocalc,代码行数:7,代码来源:CalculatePomodorosCommandTest.php

示例4: newApplication

 public function newApplication()
 {
     $application = new Application('WikibaseEntityStore');
     $application->add(new ImportJsonDumpCommand());
     $application->add(new ImportIncrementalXmlDumpCommand());
     return $application;
 }
开发者ID:SRMSE,项目名称:cron-wikidata,代码行数:7,代码来源:CliApplicationFactory.php

示例5: __invoke

 /**
  * @param ContainerInterface $container
  * @param string $requestedName
  * @param array $options, optional
  *
  * @return Application
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $cliApplication = new Application('AsseticBundle', '1.7.0');
     $cliApplication->add(new BuildCommand($container->get('AsseticService')));
     $cliApplication->add(new SetupCommand($container->get('AsseticService')));
     return $cliApplication;
 }
开发者ID:widmogrod,项目名称:zf2-assetic-module,代码行数:14,代码来源:ApplicationFactory.php

示例6: load

 public function load(Application $application)
 {
     $in = $this->container->getParameter('seed.directory');
     //add seed:load and seed:unload commands
     $application->add($this->container->get('seed.load_seeds_command'));
     $application->add($this->container->get('seed.unload_seeds_command'));
     //Go through bundles and add *Seeds available in seed.directory
     foreach ($application->getKernel()->getBundles() as $bundle) {
         if (!is_dir($dir = sprintf('%s/%s', $bundle->getPath(), $in))) {
             continue;
         }
         $finder = new Finder();
         $finder->files()->name('*Seed.php')->in($dir);
         $prefix = $bundle->getNameSpace() . '\\' . strtr($in, '/', '\\');
         foreach ($finder as $file) {
             $ns = $prefix;
             if ($relativePath = $file->getRelativePath()) {
                 $ns .= '\\' . strtr($relativePath, '/', '\\');
             }
             $class = $ns . '\\' . $file->getBasename('.php');
             $alias = 'seed.command.' . strtolower(str_replace('\\', '_', $class));
             if ($this->container->has($alias)) {
                 continue;
             }
             $r = new \ReflectionClass($class);
             if ($r->isSubclassOf('Soyuka\\SeedBundle\\Command\\Seed') && !$r->isAbstract() && ($r->hasMethod('load') || $r->hasMethod('unload'))) {
                 $application->add($r->newInstanceArgs([$this->prefix, $this->separator]));
             }
         }
     }
 }
开发者ID:soyuka,项目名称:SeedBundle,代码行数:31,代码来源:Loader.php

示例7: getCommandTester

 protected function getCommandTester()
 {
     $this->application->add($this->command);
     $command = $this->application->find('phpci:create-build');
     $commandTester = new CommandTester($command);
     return $commandTester;
 }
开发者ID:nelsonyang0710,项目名称:PHPCI,代码行数:7,代码来源:CreateBuildCommandTest.php

示例8: add

 public function add(Command $command, $namespace = '')
 {
     if (strlen($namespace)) {
         $command->setName($namespace . ':' . $command->getName());
     }
     $this->app->add($command);
 }
开发者ID:maslosoft,项目名称:sitcom,代码行数:7,代码来源:CommandWrapper.php

示例9: setupConsoleCommands

 /**
  * Instantiate and adds the console commands to 
  * the console application
  * 
  * @return $this
  */
 protected function setupConsoleCommands()
 {
     foreach ($this->commandClasses() as $class) {
         $this->consoleApplication->add(new $class());
     }
     return $this;
 }
开发者ID:staffanselander,项目名称:RestaurangOnlineDevelopmentConsole,代码行数:13,代码来源:Application.php

示例10: setUp

 protected function setUp()
 {
     $tempFile = tempnam(sys_get_temp_dir(), 'sonata_');
     if (file_exists($tempFile)) {
         unlink($tempFile);
     }
     if (mkdir($tempFile)) {
         $this->tempDirectory = $tempFile;
         file_put_contents($this->tempDirectory . '/classes.map', '<?php return array(\'Sonata\\AdminBundle\\Tests\\Fixtures\\Controller\\FooAdminController\', \'Sonata\\AdminBundle\\Tests\\Fixtures\\Controller\\BarAdminController\',);');
     } else {
         $this->markTestSkipped(sprintf('Temp directory "%s" creation error.', $tempFile));
     }
     $this->application = new Application();
     $command = new CreateClassCacheCommand();
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface');
     $kernel->expects($this->any())->method('getCacheDir')->will($this->returnValue($this->tempDirectory));
     $kernel->expects($this->any())->method('isDebug')->will($this->returnValue(false));
     $container->expects($this->any())->method('get')->will($this->returnCallback(function ($id) use($kernel) {
         if ($id == 'kernel') {
             return $kernel;
         }
         return;
     }));
     $command->setContainer($container);
     $this->application->add($command);
 }
开发者ID:clavier-souris,项目名称:SonataAdminBundle,代码行数:27,代码来源:CreateClassCacheCommandTest.php

示例11: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $controller = $this->createMock(ControllerInterface::class);
     $scheduler = $this->createMock(SchedulerInterface::class);
     $registry = new IteratorRegistry();
     $this->container = $this->createMock(ContainerInterface::class);
     $this->container->expects($this->any())->method('get')->will($this->returnCallback(function ($key) use($scheduler, $registry, $controller) {
         if ($key == 'abc.scheduler.scheduler') {
             return $scheduler;
         } elseif ($key == 'abc.scheduler.iterator_registry') {
             return $registry;
         } elseif ($key == 'abc.process_control.controller') {
             return $controller;
         }
     }));
     $controller->expects($this->any())->method('doStop')->willReturn(false);
     $command = new SchedulerProcessCommand();
     $command->setContainer($this->container);
     $kernel = $this->createMock(KernelInterface::class);
     $this->application = new Application($kernel);
     $this->application->add($command);
     $this->scheduler = $scheduler;
     $this->registry = $registry;
     $this->controller = $controller;
 }
开发者ID:aboutcoders,项目名称:scheduler-bundle,代码行数:28,代码来源:SchedulerProcessCommandTest.php

示例12: createTester

 protected function createTester(ContainerAwareInterface $obj, $shortcat)
 {
     $this->app->add($obj);
     $command = $this->app->find($shortcat);
     $obj->setContainer($this->container);
     return new CommandTester($command);
 }
开发者ID:symfony-bundles,项目名称:event-queue-bundle,代码行数:7,代码来源:ConsoleTestCase.php

示例13: registerCommands

 /**
  * {@inheritDoc}
  */
 public function registerCommands(Application $_application)
 {
     $_application->add(new Command\SetupCommand());
     $_application->add(new Command\DumpCommand());
     $_application->add(new Command\WorkflowCommand());
     $_application->add(new Command\FileCommand());
 }
开发者ID:symforce,项目名称:symforce-admin,代码行数:10,代码来源:SymforceAdminBundle.php

示例14: init

 /**
  * ConsoleProvider constructor.
  * @param Application $cli
  * @param array $commands
  */
 public function init(Application $cli, $commands = [])
 {
     $this->cli = $cli;
     foreach ($commands as $command) {
         $this->cli->add($this->app->get($command));
     }
 }
开发者ID:jetfirephp,项目名称:framework,代码行数:12,代码来源:ConsoleProvider.php

示例15: registerCommandWithConsole

 /**
  * @param Command $command
  * @param $index
  */
 private function registerCommandWithConsole(Command $command, $index)
 {
     $this->console->add($command);
     $command->registerAction(function () use($index) {
         $this->actions->handle($index);
     });
 }
开发者ID:somos,项目名称:framework,代码行数:11,代码来源:GoHandler.php


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