本文整理汇总了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);
}
示例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);
}
}
示例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);
}
示例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 = [];
}
示例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();
}
示例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);
}
示例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));
}
示例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));
}
示例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);
};
}
}
示例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 = [];
}
示例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());
}
示例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);
}
示例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!');
}
}
示例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);
}
示例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);
}