本文整理汇总了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();
}
示例2: setUp
public function setUp()
{
$config = new DummyConfig();
$this->application = new Application();
$this->application->add(new CliTaskCommand());
$this->execDir = getcwd() . "/vendor/opencart";
}
示例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);
}
示例4: newApplication
public function newApplication()
{
$application = new Application('WikibaseEntityStore');
$application->add(new ImportJsonDumpCommand());
$application->add(new ImportIncrementalXmlDumpCommand());
return $application;
}
示例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;
}
示例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]));
}
}
}
}
示例7: getCommandTester
protected function getCommandTester()
{
$this->application->add($this->command);
$command = $this->application->find('phpci:create-build');
$commandTester = new CommandTester($command);
return $commandTester;
}
示例8: add
public function add(Command $command, $namespace = '')
{
if (strlen($namespace)) {
$command->setName($namespace . ':' . $command->getName());
}
$this->app->add($command);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
示例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));
}
}
示例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);
});
}