本文整理汇总了PHP中Symfony\Component\Console\Application::addCommands方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::addCommands方法的具体用法?PHP Application::addCommands怎么用?PHP Application::addCommands使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Application
的用法示例。
在下文中一共展示了Application::addCommands方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setConsole
/**
* Config doctrine console
*
* @param Application $console
* @param EntityManager $entityManager
* @return Application
*/
static function setConsole(Application $console, EntityManager $entityManager)
{
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($entityManager->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($entityManager)));
$console->setHelperSet($helperSet);
$console->addCommands(array(new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand()));
return $console;
}
示例2: __construct
/**
* Services constructor.
*/
public function __construct()
{
$this->kernel = new Kernel();
$this->application = new Application('Neusta Facilior', FACILIOR_VERSION);
$this->application->setAutoExit(false);
//Creates Services Output
$this->console = new ConsoleService();
//Loads Commands into Application
$this->application->addCommands($this->kernel->commands());
}
示例3: main
/**
* command应用主入口
* @throws \Exception
*/
static function main()
{
$application = new Application();
$application->addCommands(self::createCommands());
$application->setDefaultCommand(self::DEFAULT_COMMAND_NAME);
$application->run();
}
示例4: main
/**
* command应用主入口
* @throws \Exception
*/
static function main()
{
$application = new Application();
$application->addCommands(self::createCommands());
$application->setDefaultCommand(ThumbnailCommand::COMMAND_NAME);
$application->run();
}
示例5: run
/**
* Inicializa a aplicação.
*
* @throws \Exception
*/
public function run()
{
//apenas para inicializar
Config::getInstance();
$application = new Application();
$commands = [];
/* Carregando os comandos internos */
$anna_commands = __DIR__ . DS . 'Commands' . DS;
$anna_commands = $this->loadAppCommands($anna_commands);
/* Carregandos os comandos criados pelos desenvolvedores */
$app_commands = SYS_ROOT . 'App' . DS . 'Console' . DS;
$app_commands = $this->loadAppCommands($app_commands);
/* Registra todos os comandos encontrados */
foreach ($app_commands as $cmd) {
$commands[] = new $cmd();
}
foreach ($anna_commands as $cmd) {
$class = new \ReflectionClass($cmd);
if (!$class->isAbstract()) {
$commands[] = new $cmd();
}
}
$application->addCommands($commands);
$application->run();
}
示例6: addCommands
/**
* @param Application $cli
*
* @return void
*/
public static function addCommands(Application $cli)
{
$cli->addCommands([new Command\ExecuteCommand(), new Command\GenerateCommand(), new Command\LatestCommand(), new Command\MigrateCommand(), new Command\StatusCommand(), new Command\VersionCommand(), new Command\UpToDateCommand()]);
if ($cli->getHelperSet()->has('em')) {
$cli->add(new Command\DiffCommand());
}
}
示例7: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
$this->application = new Application('Drupal Code Generator', '@git-version@');
$discovery = new GeneratorDiscovery([DCG_ROOT . '/src/Commands'], [DCG_ROOT . '/src/Templates'], new Filesystem());
$generators = $discovery->getGenerators();
$this->application->addCommands($generators);
$navigation = new Navigation();
$navigation->init($generators);
$this->application->add($navigation);
$this->command = $this->application->find('navigation');
$this->questionHelper = $this->createMock('Symfony\\Component\\Console\\Helper\\QuestionHelper');
$this->helperSet = $this->command->getHelperSet();
$this->commandTester = new CommandTester($this->command);
$this->filesystem = new Filesystem();
$this->destination = DCG_SANDBOX . '/tests';
}
示例8: main
/**
* command应用主入口
* @throws \Exception
*/
static function main()
{
$application = new Application();
$application->setAutoExit(true);
$application->addCommands(self::createCommands());
$application->run();
}
示例9: createConsole
/**
* Creates console.
*
* @param HelperSet $helperSet
* @param \Symfony\Component\Console\Command\Command[] $commands
* @return Application
*/
public function createConsole(HelperSet $helperSet, array $commands)
{
$cli = new Application($this->getName(), $this->getVersion());
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
$cli->addCommands($commands);
return $cli;
}
示例10: boot
/**
* @param CoreInterface $core
*/
protected function boot(CoreInterface $core)
{
$config = $core->make('Surume\\Config\\ConfigInterface');
$factory = $core->make('Surume\\Console\\Client\\Command\\CommandFactoryInterface');
$handler = $core->make('Surume\\Console\\Client\\Command\\CommandHandlerInterface');
$console = $core->make('Surume\\Console\\Client\\ConsoleClientInterface');
$cmds = (array) $factory->getDefinitions();
$commands = [];
foreach ($cmds as $command => $definition) {
$commands[] = $factory->create($command, [$handler]);
}
$this->symfony->addCommands($commands);
$version = $core->version();
$console->onCommand(function () use($version) {
echo "SurumePHP-v{$version}\n";
$this->symfony->run();
});
}
示例11: addCommands
/**
* @param CommandLoader $commandLoader
* @param $locations
*/
private function addCommands(CommandLoader $commandLoader, $locations, $bypassCache = false)
{
$classes = $this->classCache->getClasses('RoboCommand\\', $locations, $bypassCache);
$commands = $commandLoader->createRoboCommands($classes, $this->passThroughArgs);
$this->app->addCommands($commands);
$classes = $this->classCache->getClasses('Command\\', $locations, $bypassCache);
$commands = $commandLoader->createSymfonyCommands($classes);
$this->app->addCommands($commands);
}
示例12: run
/**
* Runs console with the given helperset.
*
* @param \Symfony\Component\Console\Helper\HelperSet $helperSet
* @param \Symfony\Component\Console\Command\Command[] $commands
*
* @return void
*/
public static function run(HelperSet $helperSet, $commands = array(), OutputInterface $output = null)
{
$cli = new Application('Doctrine Command Line Interface', Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
$cli->setAutoExit(false);
$commands = array_merge(self::getDefaultCommands(), $commands);
$cli->addCommands($commands);
$cli->run(null, $output);
}
示例13: provideApp
/** @Provides("Symfony\Component\Console\Application") @Singleton */
static function provideApp($name = "UNKNOWN", $version = "UNKNOWN", $helpers = [], $commands = [])
{
$app = new Application($name, $version);
$app->addCommands($commands);
$helperSet = $app->getHelperSet();
foreach ($helpers as $alias => $helper) {
$helperSet->set($helper, $alias);
}
return $app;
}
示例14: 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');
}
示例15: createService
/**
* Sets the dojo theme to use.
*
* @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
* @return \Symfony\Component\Console\Application
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config')['sds']['dojo'];
$configHelper = new \Sds\DojoModule\Tools\Console\Helper\ConfigHelper($config);
$helperSet = new HelperSet();
$helperSet->set($configHelper, 'config');
$cli = new Application();
$cli->setName('DojoModule Command Line Interface');
$cli->setHelperSet($helperSet);
$cli->addCommands(array(new \Sds\DojoModule\Tools\Console\Command\GenerateProfile()));
return $cli;
}