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


PHP Application::all方法代码示例

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


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

示例1: getListCommands

 /**
  * Get list commands to array strings
  * 
  * @return array
  */
 protected function getListCommands()
 {
     $commands = $this->application->all();
     $commandsArray = array();
     foreach ($commands as $command) {
         $commandsArray[] = array('class' => get_class($command), 'name' => $command->getName());
     }
     return $commandsArray;
 }
开发者ID:simple-php-mvc,项目名称:installer-module,代码行数:14,代码来源:BaseController.php

示例2: run

 public function run()
 {
     if ($this->container->getConfig()->get('app.debug')) {
         foreach ($this->app->all() as $commandKey => $command) {
             if (method_exists($command, 'isVagrant') && $command->isVagrant()) {
                 $this->toggleVagrantCommand($commandKey, $command);
             }
         }
     }
     $this->app->run();
 }
开发者ID:sinergi,项目名称:core,代码行数:11,代码来源:CommandRuntime.php

示例3: getCronTasks

 /**
  * @param Application $application
  * @param callback|null $filter
  * @return CronTaskInfo[]
  */
 public function getCronTasks(Application $application, $filter = null)
 {
     if ($filter === null) {
         $filter = function (Reader $reader) {
             return $reader->getParameter('crontab');
         };
     }
     if (!is_callable($filter)) {
         throw new \InvalidArgumentException('Invalid filter callback');
     }
     $tasks = [];
     foreach ($application->all() as $command) {
         $reader = new \DocBlockReader\Reader(get_class($command));
         $crontabAnnotations = $filter($reader);
         if (empty($crontabAnnotations)) {
             continue;
         }
         if (!is_array($crontabAnnotations)) {
             $crontabAnnotations = [$crontabAnnotations];
         }
         foreach ($crontabAnnotations as $crontabExpression) {
             $commandArguments = preg_split('!\\s+!', $crontabExpression, -1, PREG_SPLIT_NO_EMPTY);
             array_splice($commandArguments, 0, 5);
             $commandArguments = implode(' ', $commandArguments);
             $preparedExpression = trim(str_replace([" /", $commandArguments], [' */', ''], " " . $crontabExpression));
             $tasks[] = new CronTaskInfo($preparedExpression, $command, $commandArguments);
         }
     }
     return $tasks;
 }
开发者ID:funivan,项目名称:console,代码行数:35,代码来源:CronTasksFinder.php

示例4: testDescribeApplication

 /** @dataProvider getDescribeApplicationTestData */
 public function testDescribeApplication(Application $application, $expectedDescription)
 {
     // Replaces the dynamic placeholders of the command help text with a static version.
     // The placeholder %command.full_name% includes the script path that is not predictable
     // and can not be tested against.
     foreach ($application->all() as $command) {
         $command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp()));
     }
     $this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $this->getDescriptor()->describe($application))));
 }
开发者ID:bardascat,项目名称:blogify,代码行数:11,代码来源:AbstractDescriptorTest.php

示例5: testAdd

 public function testAdd()
 {
     $application = new Application();
     $application->add($foo = new \FooCommand());
     $commands = $application->all();
     $this->assertEquals($foo, $commands['foo:bar'], '->add() registers a command');
     $application = new Application();
     $application->addCommands(array($foo = new \FooCommand(), $foo1 = new \Foo1Command()));
     $commands = $application->all();
     $this->assertEquals(array($foo, $foo1), array($commands['foo:bar'], $commands['foo:bar1']), '->addCommands() registers an array of commands');
 }
开发者ID:spf13,项目名称:symfony,代码行数:11,代码来源:ApplicationTest.php

示例6: completeForCommandName

 /**
  * Attempt to complete the current word as a command name
  *
  * @return array|false
  */
 protected function completeForCommandName()
 {
     if (!$this->command || count($this->context->getWords()) == 2 && $this->context->getWordIndex() == 1) {
         $commands = $this->application->all();
         $names = array_keys($commands);
         if ($key = array_search('_completion', $names)) {
             unset($names[$key]);
         }
         return $names;
     }
     return false;
 }
开发者ID:stecman,项目名称:symfony-console-completion,代码行数:17,代码来源:CompletionHandler.php

示例7: inspectApplication

 private function inspectApplication()
 {
     $this->commands = array();
     $this->namespaces = array();
     $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
     foreach ($this->sortCommands($all) as $namespace => $commands) {
         $names = array();
         /** @var Command $command */
         foreach ($commands as $name => $command) {
             if (!$command->getName()) {
                 continue;
             }
             if ($command->getName() === $name) {
                 $this->commands[$name] = $command;
             } else {
                 $this->aliases[$name] = $command;
             }
             $names[] = $name;
         }
         $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
     }
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:22,代码来源:ApplicationDescription.php

示例8: all

 public function all($namespace = null)
 {
     $commands = parent::all($namespace);
     // Remove hidden command to prevent listing commands by ListCommand
     foreach ($commands as $name => $command) {
         if (method_exists($command, "getDefinedTask")) {
             // Consider the command Altax\Command\Command instance
             $definedTask = $command->getDefinedTask();
             if ($definedTask->isHidden()) {
                 unset($commands[$name]);
             }
         }
     }
     return $commands;
 }
开发者ID:kohkimakimoto,项目名称:altax,代码行数:15,代码来源:Application.php

示例9: all

 /**
  * {@inheritdoc}
  */
 public function all($namespace = null)
 {
     $this->registerCommands();
     return parent::all($namespace);
 }
开发者ID:robhaverkort,项目名称:belasting,代码行数:8,代码来源:Application.php

示例10: ensureStaticCommandHelp

 /**
  * Replaces the dynamic placeholders of the command help text with a static version.
  * The placeholder %command.full_name% includes the script path that is not predictable
  * and can not be tested against.
  */
 protected function ensureStaticCommandHelp(Application $application)
 {
     foreach ($application->all() as $command) {
         $command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp()));
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:11,代码来源:ApplicationTest.php

示例11: EntityManagerHelper

<?php

$app = (require_once __DIR__ . '/bootstrap.php');
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\DialogHelper;
use Doctrine\DBAL\Migrations\Tools\Console\Command;
use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Symfony\Component\Console\Application as SymfonyApplication;
$helpers['em'] = new EntityManagerHelper($app['orm.em']);
$helpers['dialog'] = new DialogHelper();
$helperSet = new HelperSet($helpers);
$commands = array(new Command\DiffCommand(), new Command\ExecuteCommand(), new Command\GenerateCommand(), new Command\MigrateCommand(), new Command\StatusCommand(), new Command\VersionCommand());
$application = new SymfonyApplication();
$config = new Configuration($app['db']);
$config->setName('Skel Migration');
$config->setMigrationsDirectory(__DIR__ . '/data/DoctrineMigrations');
$config->setMigrationsNamespace('Application\\Migrations');
$config->setMigrationsTableName('migration_version');
foreach ($commands as $command) {
    if ($command instanceof Command\AbstractCommand) {
        $command->setMigrationConfiguration($config);
    }
    $application->add($command);
}
ConsoleRunner::run($helperSet, $application->all());
开发者ID:rodrigogattermann,项目名称:silex-skel,代码行数:27,代码来源:console.php

示例12: all

 /**
  * Autocomplete invokes this method to get the command name completiongs.
  * If autocomplete is invoked before a command has been run, then
  * we need to initialize the application (and register the commands).
  *
  * {@inheritDoc}
  */
 public function all($namespace = null)
 {
     $this->init();
     return parent::all($namespace);
 }
开发者ID:hason,项目名称:phpcr-shell,代码行数:12,代码来源:ShellApplication.php

示例13: getRegisteredCommands

 /**
  * @return \Symfony\Component\Console\Command\Command[]
  */
 public function getRegisteredCommands()
 {
     return $this->app->all();
 }
开发者ID:twhiston,项目名称:tg,代码行数:7,代码来源:Tg.php

示例14: init

 /**
  * Initialize manager.
  *
  * @param   Application $application
  */
 public function init(Application $application)
 {
     $this->application = $application;
     if ($this->chains) {
         $commandMap = array_flip(array_reverse(array_map(function ($command) {
             return get_class($command);
         }, $application->all())));
         $chains = $this->chains;
         $members = [];
         foreach ($chains as $mainCommand => $hisMembers) {
             foreach ($hisMembers as $i => $memberClass) {
                 if (isset($commandMap[$memberClass])) {
                     $memberCommand = $commandMap[$memberClass];
                     $chains[$mainCommand][$i] = $memberCommand;
                     $members[$memberCommand][] = $mainCommand;
                 } else {
                     throw new \InvalidArgumentException(sprintf('Command from class "%s" registered as member of "%s" command, but not enabled or incorrect.', $memberClass, $mainCommand));
                 }
             }
         }
         $this->chains = $chains;
         $this->members = $members;
     }
 }
开发者ID:relo-san,项目名称:CommandChainTest,代码行数:29,代码来源:ChainManager.php


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