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


PHP Command::initialize方法代码示例

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


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

示例1: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->io = new SymfonyStyle($input, $output);
     $debug = $output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG;
     $this->cff = new CffClient($debug);
 }
开发者ID:maidmaid,项目名称:cffie,代码行数:7,代码来源:QueryCommand.php

示例2: initialize

 /**
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @throws \InvalidArgumentException When the number of messages to consume is less than 0
  * @throws \BadFunctionCallException When the pcntl is not installed and option -s is true
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     if (defined('AMQP_WITHOUT_SIGNALS') === false) {
         define('AMQP_WITHOUT_SIGNALS', $input->getOption('without-signals'));
     }
     if (!AMQP_WITHOUT_SIGNALS && extension_loaded('pcntl')) {
         if (!function_exists('pcntl_signal')) {
             throw new \BadFunctionCallException("Function 'pcntl_signal' is referenced in the php.ini 'disable_functions' and can't be called.");
         }
         pcntl_signal(SIGTERM, [$this, 'signalTerm']);
         pcntl_signal(SIGINT, [$this, 'signalInt']);
         pcntl_signal(SIGHUP, [$this, 'signalHup']);
     }
     if (defined('AMQP_DEBUG') === false) {
         define('AMQP_DEBUG', (bool) $input->getOption('debug'));
     }
     if (($this->amount = $input->getOption('messages')) < 0) {
         throw new \InvalidArgumentException("The -m option should be null or greater than 0");
     }
     $this->consumer = $this->connection->getConsumer($input->getArgument('name'));
     if (!is_null($input->getOption('memory-limit')) && ctype_digit((string) $input->getOption('memory-limit')) && $input->getOption('memory-limit') > 0) {
         $this->consumer->setMemoryLimit($input->getOption('memory-limit'));
     }
     if ($routingKey = $input->getOption('route')) {
         $this->consumer->setRoutingKey($routingKey);
     }
 }
开发者ID:kdyby,项目名称:rabbitmq,代码行数:35,代码来源:BaseConsumerCommand.php

示例3: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) {
         $input->setOption('no-progress', true);
     }
     parent::initialize($input, $output);
 }
开发者ID:VicDeo,项目名称:poc,代码行数:7,代码来源:Command.php

示例4: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->schema->onIndexDropped[] = function ($sm, $index) use($output) {
         $output->writeln(sprintf('<error>Dropped</error> index <info>%s</info>', $index));
     };
     $this->schema->onTypeDropped[] = function ($sm, ClassMetadata $type) use($output) {
         $output->writeln(sprintf('<error>Dropped</error> type <info>%s</info>', $type->getName()));
     };
     $this->schema->onIndexCreated[] = function ($sm, $index) use($output) {
         $output->writeln(sprintf('Created index <info>%s</info>', $index));
     };
     $this->schema->onTypeCreated[] = function ($sm, ClassMetadata $type) use($output) {
         $output->writeln(sprintf('Created type <info>%s</info>', $type->getName()));
     };
     $this->schema->onAliasCreated[] = function ($sm, $original, $alias) use($output) {
         $output->writeln(sprintf('Created alias <info>%s</info> for index <info>%s</info>', $alias, $original));
     };
     $this->schema->onAliasError[] = function ($sm, ResponseException $e, $original, $alias) use($output) {
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
     };
     /** @var \Doctrine\Search\ElasticSearch\Client $searchClient */
     $searchClient = $this->searchManager->getClient();
     /** @var Kdyby\ElasticSearch\Client $apiClient */
     $apiClient = $searchClient->getClient();
     $apiClient->onError = [];
     $apiClient->onSuccess = [];
 }
开发者ID:rohlikcz,项目名称:DoctrineSearch,代码行数:28,代码来源:CreateMappingCommand.php

示例5: initialize

 /**
  * {@inheritdoc}
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     // Don't use IO from container, because it contains outer IO which doesn't reflect sub-command calls.
     $this->io = new ConsoleIO($input, $output, $this->getHelperSet());
     $this->prepareDependencies();
 }
开发者ID:console-helpers,项目名称:console-kit,代码行数:10,代码来源:AbstractCommand.php

示例6: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->in = $input;
     $this->out = $output;
     $this->io = new SymfonyStyle($this->in, $this->out);
 }
开发者ID:afflicto,项目名称:webdev,代码行数:7,代码来源:Command.php

示例7: initialize

 /**
  * {@inheritdoc}
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $factory = new HexFactory();
     $hex = $input->getArgument(self::HEX_ARGUMENT);
     $input->setArgument(self::HEX_ARGUMENT, $factory->make($hex));
 }
开发者ID:epfremmer,项目名称:PHP-Weekly-Issue36,代码行数:10,代码来源:HexToPhoneticCommand.php

示例8: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->profileManager = new Manager(null, $output);
     $config = new Config();
     $this->dependencyTracker = new DependencyTracker();
     $this->blueprintFactory = new BlueprintFactory($config, new \StackFormation\ValueResolver\ValueResolver($this->dependencyTracker, $this->profileManager, $config));
 }
开发者ID:aoepeople,项目名称:stackformation,代码行数:8,代码来源:AbstractCommand.php

示例9: initialize

 /**
  * @param InputInterface $input An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @throws \InvalidArgumentException When the number of messages to consume is less than 0
  * @throws \BadFunctionCallException When the pcntl is not installed and option -s is true
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     if (defined('AMQP_WITHOUT_SIGNALS') === false) {
         define('AMQP_WITHOUT_SIGNALS', $input->getOption('without-signals'));
     }
     if (defined('AMQP_DEBUG') === false) {
         define('AMQP_DEBUG', (bool) $input->getOption('debug'));
     }
     if (($this->amount = $input->getOption('messages')) < 0) {
         throw new \InvalidArgumentException("The -m option should be null or greater than 0");
     }
     $name = $input->getArgument('name');
     try {
         $this->consumer = $this->connection->getConsumer($name);
     } catch (InvalidArgumentException $e) {
         $names = implode(', ', $this->connection->getDefinedConsumers());
         throw new InvalidArgumentException("Unknown consumer {$name}, expecting one of [{$names}]\nIf you added or renamed a consumer, run 'rabbitmq:setup-fabric'");
     }
     if (!is_null($input->getOption('memory-limit')) && ctype_digit((string) $input->getOption('memory-limit')) && $input->getOption('memory-limit') > 0) {
         $this->consumer->setMemoryLimit($input->getOption('memory-limit'));
     }
     if ($routingKey = $input->getOption('route')) {
         $this->consumer->setRoutingKey($routingKey);
     }
     if (!AMQP_WITHOUT_SIGNALS && extension_loaded('pcntl')) {
         if (!function_exists('pcntl_signal')) {
             throw new \BadFunctionCallException("Function 'pcntl_signal' is referenced in the php.ini 'disable_functions' and can't be called.");
         }
         $this->consumer->onConsume[] = function () {
             pcntl_signal(SIGTERM, function () {
                 if ($this->consumer) {
                     pcntl_signal(SIGTERM, SIG_DFL);
                     $this->consumer->forceStopConsumer();
                 }
             });
             pcntl_signal(SIGINT, function () {
                 if ($this->consumer) {
                     pcntl_signal(SIGINT, SIG_DFL);
                     $this->consumer->forceStopConsumer();
                 }
             });
             pcntl_signal(SIGHUP, function () {
                 if ($this->consumer) {
                     pcntl_signal(SIGHUP, SIG_DFL);
                     $this->consumer->forceStopConsumer();
                 }
                 // TODO: Implement restarting of consumer
             });
         };
         $this->consumer->onConsumeStop[] = function () {
             pcntl_signal(SIGTERM, SIG_DFL);
             pcntl_signal(SIGINT, SIG_DFL);
             pcntl_signal(SIGHUP, SIG_DFL);
         };
     }
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:64,代码来源:BaseConsumerCommand.php

示例10: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     /** @var \Doctrine\Search\ElasticSearch\Client $searchClient */
     $searchClient = $this->searchManager->getClient();
     /** @var Kdyby\ElasticSearch\Client $apiClient */
     $apiClient = $searchClient->getClient();
     $apiClient->onError = [];
     $apiClient->onSuccess = [];
 }
开发者ID:rohlikcz,项目名称:DoctrineSearch,代码行数:10,代码来源:PipeEntitiesCommand.php

示例11: initialize

 /**
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $configPath = $input->getOption('config');
     $this->config = $configPath ? Configuration::fromFile($configPath) : Configuration::defaults('php-semver-checker');
     $inputMerger = new InputMerger();
     $inputMerger->merge($input, $this->config);
     // Set overrides
     LevelMapping::setOverrides($this->config->getLevelMapping());
 }
开发者ID:nochso,项目名称:php-semver-checker,代码行数:14,代码来源:BaseCommand.php

示例12: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     /** @var OutputFormatterStyleInterface $warningStyle */
     $warningStyle = $this->pimple['console.style.warning'];
     $output->getFormatter()->setStyle('warning', $warningStyle);
     /** @var OutputFormatterStyleInterface $warningStyle */
     $warningStyle = $this->pimple['console.style.success'];
     $output->getFormatter()->setStyle('success', $warningStyle);
 }
开发者ID:mykanoa,项目名称:kanoa,代码行数:10,代码来源:AbstractPimpleCommand.php

示例13: initialize

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->input = $input;
     $this->output = $output;
     // use Console\Dumper for nice debug output
     $this->dumper = new Dumper($this->output);
     // skip if maintenance mode is on and the flag is not set
     if (Admin::isInMaintenanceMode() && !$input->getOption('ignore-maintenance-mode')) {
         throw new \RuntimeException('In maintenance mode - set the flag --ignore-maintenance-mode to force execution!');
     }
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:16,代码来源:AbstractCommand.php

示例14: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->input = $input;
     $this->output = $output;
     $adapter = new Adapter(self::ROOT_DIR);
     $this->fs = new Filesystem($adapter);
     $this->projectName = trim($input->getArgument('projectName'));
     $this->packages = $input->getOption('with');
     $this->projectDir = self::ROOT_DIR . DIRECTORY_SEPARATOR . $this->projectName;
     //$this->setOption($this->option);
     //$this->setPackageOptions($this->packages);
 }
开发者ID:smolinari,项目名称:initializer,代码行数:13,代码来源:NewCommand.php

示例15: initialize

 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $host = $input->getOption('host');
     if ($host[0] == '/') {
         $host = 'unix:///' . ltrim($host, '/');
         $port = null;
     } elseif (substr($host, 0, 7) != 'unix://') {
         list($host, $port) = array_pad(explode(':', $host, 2), 2, 9000);
     } else {
         $port = null;
     }
     $this->connector = $this->createConnectorInstance($host, $port);
     parent::initialize($input, $output);
 }
开发者ID:jobcloud,项目名称:CacheControl,代码行数:14,代码来源:AbstractHandlerCommand.php


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