本文整理匯總了PHP中Symfony\Component\Console\Event\ConsoleCommandEvent::stopPropagation方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConsoleCommandEvent::stopPropagation方法的具體用法?PHP ConsoleCommandEvent::stopPropagation怎麽用?PHP ConsoleCommandEvent::stopPropagation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Event\ConsoleCommandEvent
的用法示例。
在下文中一共展示了ConsoleCommandEvent::stopPropagation方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onConsoleCommand
/**
* Disabling runs members of chains and launching chains of commands.
*
* @param ConsoleCommandEvent $event
*/
public function onConsoleCommand(ConsoleCommandEvent $event)
{
$command = $event->getCommand();
$commandName = $command->getName();
$application = $command->getApplication();
if (!$this->manager->isInitialized()) {
$this->manager->init($application);
}
if ($this->manager->isMember($commandName)) {
$event->disableCommand();
$event->stopPropagation();
$mainCommands = $this->manager->getMainCommands($commandName);
$event->getOutput()->writeln(sprintf('<error>Error: "%s" command is a member of %s command%s chain and cannot be executed on its own.</error>', $commandName, implode(', ', array_map(function ($name) {
return '"' . $name . '"';
}, $mainCommands)), count($mainCommands) > 1 ? 's' : ''));
}
if ($this->manager->hasChains($commandName)) {
$this->manager->runChain($command, $event->getInput());
$event->disableCommand();
$event->stopPropagation();
}
}
示例2: 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);
}
示例3: onCommand
public function onCommand(ConsoleCommandEvent $event)
{
$composer_json_path = 'composer.json';
if (file_exists($composer_json_path)) {
return;
}
/** @var QuestionHelper $questionHelper */
$questionHelper = $event->getCommand()->getHelper('question');
$question = new ConfirmationQuestion('Composer has not been initialized, initialize composer now? [yes]: ', true);
if (!$questionHelper->ask($event->getInput(), $event->getOutput(), $question)) {
$event->getOutput()->writeln('Skipping composer init, if the command fails then you should try initializing composer.');
return;
}
/** @var InitHelper $initHelper */
$initHelper = $event->getCommand()->getHelper('composer init');
if ($initHelper->initComposer($event->getOutput())) {
$event->getOutput()->writeln("Composer initialization failed.");
$event->getOutput()->writeln("Please initialize a composer package manually before trying again.");
$event->disableCommand();
$event->stopPropagation();
}
}