本文整理汇总了PHP中Symfony\Component\Console\Event\ConsoleCommandEvent::getInput方法的典型用法代码示例。如果您正苦于以下问题:PHP ConsoleCommandEvent::getInput方法的具体用法?PHP ConsoleCommandEvent::getInput怎么用?PHP ConsoleCommandEvent::getInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Event\ConsoleCommandEvent
的用法示例。
在下文中一共展示了ConsoleCommandEvent::getInput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onConsoleCommand
/**
* @param ConsoleCommandEvent $event
*/
public function onConsoleCommand(ConsoleCommandEvent $event)
{
$command = $event->getCommand();
if ($command instanceof HelpCommand) {
$command = $this->getCommandFromHelpCommand($command, $event->getInput());
}
if (!$command instanceof FormBasedCommand) {
return;
}
$inputDefinition = $this->inputDefinitionFactory->createForFormType($command->formType());
$this->setInputDefinition($command, $event->getInput(), $inputDefinition);
}
开发者ID:bangpound,项目名称:symfony-console-form,代码行数:15,代码来源:SetInputDefinitionOfFormBasedCommandEventListener.php
示例2: checkBundleForTranslatingRoutes
/**
* This function saves the bundle whose routes shall be translated in a global variable to be used in
* Zikula\RoutesModule\Translation\DefaultRouteExclusionStrategy later on.
*
* @param ConsoleCommandEvent $event
*/
public function checkBundleForTranslatingRoutes(ConsoleCommandEvent $event)
{
if ($event->getCommand()->getName() !== 'translation:extract') {
return;
}
$GLOBALS['translation_extract_routes'] = true;
if ($event->getInput()->hasParameterOption('--bundle')) {
$bundle = $event->getInput()->getParameterOption('--bundle');
if ('@' === $bundle[0]) {
$bundle = substr($bundle, 1);
}
$GLOBALS['translation_extract_routes_bundle'] = $bundle;
}
}
示例3: setGlobalOptions
/**
* Before a Console command runs, examine the global
* commandline options from the event Input, and set
* configuration values as appropriate.
*
* @param ConsoleCommandEvent $event
*/
public function setGlobalOptions(ConsoleCommandEvent $event)
{
/* @var Input $input */
$input = $event->getInput();
// TODO: We need a good strategy for managing global options.
// $simulate = $input->getOption('simulate');
}
示例4: onConsoleCommand
/**
* @param ConsoleCommandEvent $event
*/
public function onConsoleCommand(ConsoleCommandEvent $event)
{
$command = $event->getCommand();
$input = $event->getInput();
if (in_array($command->getName(), $this->ignoredCommands)) {
$this->interactor->ignoreTransaction();
}
if ($this->newRelic->getName()) {
$this->interactor->setApplicationName($this->newRelic->getName(), $this->newRelic->getLicenseKey(), $this->newRelic->getXmit());
}
$this->interactor->setTransactionName($command->getName());
$this->interactor->enableBackgroundJob();
// send parameters to New Relic
foreach ($input->getOptions() as $key => $value) {
$key = '--' . $key;
if (is_array($value)) {
foreach ($value as $k => $v) {
$this->interactor->addCustomParameter($key . '[' . $k . ']', $v);
}
} else {
$this->interactor->addCustomParameter($key, $value);
}
}
foreach ($input->getArguments() as $key => $value) {
if (is_array($value)) {
foreach ($value as $k => $v) {
$this->interactor->addCustomParameter($key . '[' . $k . ']', $v);
}
} else {
$this->interactor->addCustomParameter($key, $value);
}
}
}
示例5: onCronStart
/**
* @param ConsoleCommandEvent $event
*/
public function onCronStart(ConsoleCommandEvent $event)
{
if (!$this->isCronCommand($event->getCommand()->getName(), $event->getInput())) {
$this->skipped = true;
return;
}
$this->start = microtime(true);
}
示例6: onConsoleCommand
public function onConsoleCommand(ConsoleCommandEvent $event)
{
$this->siteAccess->name = $event->getInput()->getParameterOption('--siteaccess', $this->defaultSiteAccessName);
$this->siteAccess->matchingType = 'cli';
if (!in_array($this->siteAccess->name, $this->siteAccessList)) {
throw new InvalidSiteAccessException($this->siteAccess->name, $this->siteAccessList, $this->siteAccess->matchingType);
}
$this->eventDispatcher->dispatch(MVCEvents::CONFIG_SCOPE_CHANGE, new ScopeChangeEvent($this->siteAccess));
}
示例7: onConsoleCommand
/**
* @param ConsoleCommandEvent $event
*/
public function onConsoleCommand(ConsoleCommandEvent $event)
{
$command = $event->getCommand();
$input = $event->getInput();
$this->addOptionsToCommand($command, $input);
$listeners = $this->getListenersToDisable($input);
if (!empty($listeners)) {
$this->listenersManager->disableListeners($listeners);
}
}
示例8: initializeEventIo
/**
* @see getSubscribedEvents
*
* @param ConsoleCommandEvent $event
*/
public function initializeEventIo(ConsoleCommandEvent $event)
{
$set = $event->getCommand()->getHelperSet();
if (!$set->has(self::HELPER_NAME)) {
return;
}
/** @var $helper IoHelper */
$helper = $set->get(self::HELPER_NAME);
$helper->initializeIo($event->getInput(), $event->getOutput());
}
示例9: onConsoleCommand
/**
* @param ConsoleCommandEvent $event
*/
public function onConsoleCommand(ConsoleCommandEvent $event)
{
$command = $event->getCommand();
if (!$command instanceof FormBasedCommand) {
return;
}
$input = $event->getInput();
$output = $event->getOutput();
$formData = $this->formQuestionHelper->interactUsingForm($command->formType(), $input, $output);
$command->setFormData($formData);
}
示例10: initialize
public function initialize(ConsoleCommandEvent $event)
{
$command = $event->getCommand();
if (!$command instanceof TableFeature) {
return;
}
$input = $event->getInput();
$layout = $input->getOption('table-layout');
if ($layout && !in_array($layout, $this->validLayouts, true)) {
throw new \InvalidArgumentException(sprintf('The table-layout option must be passed one of "%s" but was given "%s"', implode(', ', $this->validLayouts), $layout));
}
}
示例11: alterCommandOptions
/**
* @param ConsoleCommandEvent $event
*/
public function alterCommandOptions(ConsoleCommandEvent $event)
{
/* @var Command $command */
$command = $event->getCommand();
$input = $event->getInput();
if ($command->getName() == 'help') {
// Symfony 3.x prepares $input for us; Symfony 2.x, on the other
// hand, passes it in prior to binding with the command definition,
// so we have to go to a little extra work. It may be inadvisable
// to do these steps for commands other than 'help'.
if (!$input->hasArgument('command_name')) {
$command->ignoreValidationErrors();
$command->mergeApplicationDefinition();
$input->bind($command->getDefinition());
}
$nameOfCommandToDescribe = $event->getInput()->getArgument('command_name');
$commandToDescribe = $this->application->find($nameOfCommandToDescribe);
$this->findAndAddHookOptions($commandToDescribe);
} else {
$this->findAndAddHookOptions($command);
}
}
示例12: setGlobalOptions
/**
* Before a Console command runs, examine the global
* commandline options from the event Input, and set
* configuration values as appropriate.
*
* @param \Symfony\Component\Console\Event\ConsoleCommandEvent $event
*/
public function setGlobalOptions(ConsoleCommandEvent $event)
{
$config = $this->getConfig();
$input = $event->getInput();
$globalOptions = $config->getGlobalOptionDefaultValues();
foreach ($globalOptions as $option => $default) {
$value = $input->hasOption($option) ? $input->getOption($option) : null;
// Unfortunately, the `?:` operator does not differentate between `0` and `null`
if (!isset($value)) {
$value = $default;
}
$config->set($option, $value);
}
}
示例13: initialize
public function initialize(ConsoleCommandEvent $event)
{
$command = $event->getCommand();
if ($command instanceof TemplateFeature) {
$input = $event->getInput();
$template = $input->getOption('template');
if ($template) {
$validTemplates = $this->templateHelper->getNamesForDomain($command->getTemplateDomain());
if (!in_array($template, $validTemplates, true)) {
throw new \InvalidArgumentException(sprintf('The specified template "%s" does not exist, try one of: ' . PHP_EOL . ' - %s', $template, implode(PHP_EOL . ' - ', $validTemplates)));
}
}
}
}
示例14: showMessage
/**
* @param ConsoleCommandEvent $event
*/
public function showMessage(ConsoleCommandEvent $event)
{
/**
* @var \Drupal\Console\Command\Command $command
*/
$command = $event->getCommand();
$input = $event->getInput();
$output = $event->getOutput();
$output = new DrupalStyle($input, $output);
$application = $command->getApplication();
$translatorHelper = $application->getTranslator();
$welcomeMessageKey = 'commands.' . str_replace(':', '.', $command->getName()) . '.welcome';
$welcomeMessage = $translatorHelper->trans($welcomeMessageKey);
if ($welcomeMessage != $welcomeMessageKey) {
$output->text($welcomeMessage);
}
}
示例15: onCommand
public function onCommand(ConsoleCommandEvent $event)
{
/** @var PathHelper $path */
$path = $event->getCommand()->getHelper('path');
$this->old_working_dir = getcwd();
$working_dir = $event->getInput()->getOption('project-path');
$real_working_dir = realpath($working_dir);
if (!$real_working_dir) {
$event->getOutput()->writeln(sprintf('The specified project-path "%s" does not exist.', $working_dir));
$event->stopPropagation();
$event->disableCommand();
return;
}
$path->setProjectPath($working_dir);
$event->getOutput()->writeln(sprintf("Changing directory to %s", $working_dir));
chdir($real_working_dir);
}