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


PHP Command\ContainerAwareCommand类代码示例

本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand的典型用法代码示例。如果您正苦于以下问题:PHP ContainerAwareCommand类的具体用法?PHP ContainerAwareCommand怎么用?PHP ContainerAwareCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __construct

 /**
  * @param ContainerAwareCommand $command A ContainerAwareCommand instance to test
  * @param ContainerInterface $container The container to be injected in the command to test
  */
 public function __construct(ContainerAwareCommand $command, ContainerInterface $container)
 {
     $application = new Application('Paraunit Command Test: ' . $command->getName());
     $application->add($command);
     $this->container = $container;
     $command->setContainer($container);
     parent::__construct($command);
 }
开发者ID:facile-it,项目名称:paraunit-testcase,代码行数:12,代码来源:ContainerAwareCommandTester.php

示例2: executeCommand

 /**
  * Executes specified command.
  *
  * @param ContainerAwareCommand $commandInstance
  * @param string                $commandNamespace
  * @param array                 $parameters
  *
  * @return CommandTester
  */
 protected function executeCommand(ContainerAwareCommand $commandInstance, $commandNamespace, array $parameters = [])
 {
     $application = new Application(self::createClient()->getKernel());
     $commandInstance->setContainer($this->getServiceContainer());
     $application->add($commandInstance);
     $command = $application->find($commandNamespace);
     $commandTester = new CommandTester($command);
     $commandTester->execute(array_merge_recursive(['command' => $command->getName()], $parameters));
     return $commandTester;
 }
开发者ID:arfr,项目名称:OXIDConnectorBundle,代码行数:19,代码来源:AbstractTestCase.php

示例3: testExecute

 /**
  * Check command execute.
  */
 public function testExecute()
 {
     // Parameter was not set, so it has no value.
     $this->commandTester->execute(['command' => $this->command->getName(), 'parameter' => 'test1']);
     $this->assertContains('Parameter `test1`: has no value.', $this->commandTester->getDisplay());
     $this->assertContains('If you want to write new value, use --set="<new value>" option.', $this->commandTester->getDisplay());
     // Set some value, and test if it was set and returned.
     $value = '2014-01-01 01:01:01';
     $this->commandTester->execute(['command' => $this->command->getName(), 'parameter' => 'test1', '--set' => $value]);
     $this->assertContains('New value written:', $this->commandTester->getDisplay());
     /** @var Repository $repo */
     $repo = $this->manager->getRepository('ONGRConnectionsBundle:Pair');
     $parameter = $repo->find('test1');
     $this->assertEquals($value, $parameter->getValue());
 }
开发者ID:asev,项目名称:ConnectionsBundle,代码行数:18,代码来源:SyncParametersCommandTest.php

示例4: setContainer

 /**
  * Set the service container, and initialize the command.
  *
  * @param ContainerInterface $container
  */
 public function setContainer(ContainerInterface $container = null)
 {
     parent::setContainer($container);
     $this->templating = $container->get('templating');
     $this->logger = $container->get('logger');
     $this->em = $container->get('doctrine')->getManager();
 }
开发者ID:ubermichael,项目名称:pkppln-php,代码行数:12,代码来源:ExtractDepositCommand.php

示例5: configure

 public function configure()
 {
     parent::configure();
     $this->setName('partkeepr:user:protect');
     $this->setDescription("Protects a given user against changes");
     $this->addArgument("username", InputArgument::REQUIRED, "The username to protect against changes");
 }
开发者ID:fulcrum3d,项目名称:PartKeepr,代码行数:7,代码来源:ProtectUserCommand.php

示例6: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->targetPath = $input->getOption('target') ?: sprintf('%s/../web/js/fos_js_routes.js', $this->getContainer()->getParameter('kernel.root_dir'));
     $this->extractor = $this->getContainer()->get('fos_js_routing.extractor');
     $this->serializer = $this->getContainer()->get('fos_js_routing.serializer');
 }
开发者ID:tecnocat,项目名称:FOSJsRoutingBundle,代码行数:7,代码来源:DumpCommand.php

示例7: initialize

 /**
  * Initialize Connections
  * @param InputInterface  $input  input
  * @param OutputInterface $output output
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->container = $this->getContainer();
     $this->classification = $this->container->get('consult.classification');
     $this->wordManager = $this->container->get('consult.word_manager');
 }
开发者ID:nandanprac,项目名称:capi,代码行数:12,代码来源:DataTrainingCommand.php

示例8: execute

 /**
  * 呼び出し元のコントローラーから呼び出すモデルを判定しrun()を実行します。
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // 実行中チェック
     $name = sprintf('%s.%s', $this->getName(), $input->getArgument('service'));
     $this->getContainer()->get('lib.command.manager')->createExecuting($name);
     $serviceName = $input->getArgument('service');
     $controllerClass = get_class($this);
     // サービスのディレクトリ
     $serviceDir = preg_replace('/Command$/', '', basename(str_replace('\\', '/', $controllerClass)));
     // サービスのクラス名
     $clazz = '';
     foreach (explode('-', $serviceName) as $_word) {
         $clazz .= ucwords($_word);
     }
     if ($clazz === '') {
         throw new IllegalArgumentException('serviceが指定されていません。');
     }
     $tmp = sprintf('Service\\%s\\%s', $serviceDir, $clazz);
     $classPath = preg_replace('/Command.*Command$/', $tmp, $controllerClass);
     $service = new $classPath(parent::getContainer(), $this, $input, $output);
     if (is_null($service)) {
         throw new \ErrorException('Service is not found.');
     }
     $response = $service->run();
     // 実行中チェックを削除
     $this->getContainer()->get('lib.command.manager')->removeExecuting($name);
     return $response;
 }
开发者ID:iwatea,项目名称:Swim,代码行数:31,代码来源:AbstractCommand.php

示例9: isEnabled

 /**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (!class_exists('Symfony\\Component\\Translation\\Translator')) {
         return false;
     }
     return parent::isEnabled();
 }
开发者ID:blazarecki,项目名称:symfony,代码行数:10,代码来源:TranslationDebugCommand.php

示例10: isEnabled

 /**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (version_compare(phpversion(), '5.4.0', '<')) {
         return false;
     }
     return parent::isEnabled();
 }
开发者ID:rolfmadsen,项目名称:dummy_alma,代码行数:10,代码来源:ServerRunCommand.php

示例11: getHelp

    /**
     * {@inheritdoc}
     */
    public function getHelp()
    {
        $help = parent::getHelp();
        if (null !== $help) {
            return $help;
        }
        /** @var $generators \PhpCollection\Map */
        $generators = $this->getContainer()->get('sp_fixture_dumper.generators_map');
        $help = <<<EOT
The <info>%1\$s</info> command dumps fixtures to a directory from your existing entities/documents:

  <info>./app/console %1\$s /path/to/fixtures</info>

The path argument can include parameters (like <info>%%kernel.root_dir%%</info>) and you can use
the bundle annotation (<info>@AcmeDemoBundle/DataFixtures/Fixtures</info>)

If you want to put all fixtures in one file you can use the <info>--single-file</info> option:

  <info>./app/console %1\$s --path=/path/to/fixtures --single-file</info>

You can also use different formats for the dumped fixtures (Available formats: <comment>%2\$s</comment>)

  <info>./app/console %1\$s --format=yml --single-file /path/to/fixtures</info>

Some formats require you to enter extra options, like the <comment>class</comment> format where
you have to specify the namespace.
EOT;
        return sprintf($help, $this->getName(), implode(', ', $generators->keys()));
    }
开发者ID:ibasaw,项目名称:SpFixtureDumperBundle,代码行数:32,代码来源:AbstractDumpCommand.php

示例12: isEnabled

 /**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (!$this->getContainer()->has('security.acl.dbal.connection')) {
         return false;
     }
     return parent::isEnabled();
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:10,代码来源:InitAclCommand.php

示例13: isEnabled

 /**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (defined('HHVM_VERSION')) {
         return false;
     }
     return parent::isEnabled();
 }
开发者ID:vadim2404,项目名称:symfony,代码行数:10,代码来源:ServerRunCommand.php

示例14: configure

 protected function configure()
 {
     parent::configure();
     $this->setName('debug:rpc_router');
     $this->setDescription('Display essential info about RPC routing');
     $this->addOption('endpoint', 'p', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Filter endpoint', null);
 }
开发者ID:bankiru,项目名称:rpc-server-bundle,代码行数:7,代码来源:RouterDebugCommand.php

示例15: __construct

 public function __construct(SessionManagerInterface $sessionManager, SessionInterface $defaultSession, SessionInterface $liveSession)
 {
     $this->sessionManager = $sessionManager;
     $this->defaultSession = $defaultSession;
     $this->liveSession = $liveSession;
     parent::__construct();
 }
开发者ID:sulu,项目名称:sulu,代码行数:7,代码来源:CleanupHistoryCommand.php


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