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