當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。