php Symfony-Bundle-FrameworkBundle-Command-ContainerAwareCommand类(方法)实例源码

下面列出了php Symfony-Bundle-FrameworkBundle-Command-ContainerAwareCommand 类(方法)源码代码实例,从而了解它的用法。

作者:facile-i    项目:paraunit-testcas   
/**
  * @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);
 }

作者:arf    项目:OXIDConnectorBundl   
/**
  * 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;
 }

作者:ase    项目:ConnectionsBundl   
/**
  * 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());
 }

作者:ubermichae    项目:pkppln-ph   
/**
  * 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();
 }

作者:fulcrum3    项目:PartKeep   
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");
 }

作者:tecnoca    项目:FOSJsRoutingBundl   
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');
 }

作者:nandanpra    项目:cap   
/**
  * 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');
 }

作者:iwate    项目:Swi   
/**
  * 呼び出し元のコントローラーから呼び出すモデルを判定し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;
 }

作者:blazareck    项目:symfon   
/**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (!class_exists('Symfony\\Component\\Translation\\Translator')) {
         return false;
     }
     return parent::isEnabled();
 }

作者:rolfmadse    项目:dummy_alm   
/**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (version_compare(phpversion(), '5.4.0', '<')) {
         return false;
     }
     return parent::isEnabled();
 }

作者:ibasa    项目:SpFixtureDumperBundl   
/**
     * {@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()));
    }

作者:Ener-Getic    项目:symfon   
/**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (!$this->getContainer()->has('security.acl.dbal.connection')) {
         return false;
     }
     return parent::isEnabled();
 }

作者:vadim240    项目:symfon   
/**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (defined('HHVM_VERSION')) {
         return false;
     }
     return parent::isEnabled();
 }

作者:bankir    项目:rpc-server-bundl   
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);
 }

作者:sul    项目:sul   
public function __construct(SessionManagerInterface $sessionManager, SessionInterface $defaultSession, SessionInterface $liveSession)
 {
     $this->sessionManager = $sessionManager;
     $this->defaultSession = $defaultSession;
     $this->liveSession = $liveSession;
     parent::__construct();
 }

作者:ubermichae    项目:pkppln-ph   
/**
  * 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('monolog.logger.processing');
     $this->ping = $container->get('ping');
 }

作者:mhlava    项目:GeonamesBundl   
public function __construct($name, $description = null)
 {
     parent::__construct($name);
     if ($description) {
         $this->setDescription($description);
     }
 }

作者:b-sebastia    项目:timetabl   
/**
  * {@inheritdoc}
  */
 public function isEnabled()
 {
     if (version_compare(phpversion(), '5.4.0', '<') || defined('HHVM_VERSION')) {
         return false;
     }
     return parent::isEnabled();
 }

作者:cimu    项目:gearman-bundl   
/**
  * 
  * @param InputInterface $input
  * @param OutputInterface $output
  * 
  * @return void
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     declare (ticks=1);
     pcntl_signal(SIGTERM, [$this, 'stopCommand']);
     pcntl_signal(SIGINT, [$this, 'stopCommand']);
 }

作者:ubermichae    项目:pkppln-ph   
/**
  * {@inheritdoc}
  */
 public function setContainer(ContainerInterface $container = null)
 {
     parent::setContainer($container);
     $this->logger = $container->get('logger');
     $this->em = $container->get('doctrine')->getManager();
     $this->filePaths = $container->get('filepaths');
 }


问题


面经


文章

微信
公众号

扫码关注公众号