本文整理汇总了PHP中Drupal\Console\Style\DrupalStyle::block方法的典型用法代码示例。如果您正苦于以下问题:PHP DrupalStyle::block方法的具体用法?PHP DrupalStyle::block怎么用?PHP DrupalStyle::block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Console\Style\DrupalStyle
的用法示例。
在下文中一共展示了DrupalStyle::block方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$application = $this->getApplication();
$manifest = $input->getOption('manifest') ?: 'http://drupalconsole.com/manifest.json';
$currentVersion = $input->getOption('current-version') ?: $application->getVersion();
$major = $input->getOption('major');
if (!extension_loaded('Phar') || !\Phar::running(false)) {
$io->error($this->trans('commands.self-update.messages.not-phar'));
$io->block($this->trans('commands.self-update.messages.instructions'));
return 1;
}
$io->info(sprintf($this->trans('commands.self-update.messages.check'), $currentVersion));
$updater = new Updater(null, false);
$strategy = new ManifestStrategy($currentVersion, $major, $manifest);
$updater->setStrategyObject($strategy);
if (!$updater->hasUpdate()) {
$io->info(sprintf($this->trans('commands.self-update.messages.current-version'), $currentVersion));
return 0;
}
$oldVersion = $updater->getOldVersion();
$newVersion = $updater->getNewVersion();
if (!$io->confirm(sprintf($this->trans('commands.self-update.questions.update'), $oldVersion, $newVersion), true)) {
return 1;
}
$io->comment(sprintf($this->trans('commands.self-update.messages.update'), $newVersion));
$updater->update();
$io->success(sprintf($this->trans('commands.self-update.messages.success'), $oldVersion, $newVersion));
// Errors appear if new classes are instantiated after this stage
// (namely, Symfony's ConsoleTerminateEvent). This suggests PHP
// can't read files properly from the overwritten Phar, or perhaps it's
// because the autoloader's name has changed. We avoid the problem by
// terminating now.
exit;
}
示例2: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$group = $input->getArgument('group');
if ($group) {
$breakPointData = $this->getBreakpointByName($group);
foreach ($breakPointData as $key => $breakPoint) {
$io->comment($key, false);
$io->block(Yaml::dump($breakPoint));
}
return 0;
}
$groups = array_keys($this->breakpointManager->getGroups());
$tableHeader = [$this->trans('commands.breakpoints.debug.messages.name')];
$io->table($tableHeader, $groups, 'compact');
return 0;
}
示例3: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$interactive = false;
$learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
$file = $input->getOption('file');
if (!$file) {
$io->error($this->trans('commands.chain.messages.missing_file'));
return 1;
}
$fileSystem = new Filesystem();
$file = calculateRealPath($file);
if (!$fileSystem->exists($file)) {
$io->error(sprintf($this->trans('commands.chain.messages.invalid_file'), $file));
return 1;
}
$placeholder = $input->getOption('placeholder');
if ($placeholder) {
$placeholder = $this->inlineValueAsArray($placeholder);
}
$chainContent = $this->getFileContents($file);
$environmentPlaceHolders = $this->extractEnvironmentPlaceHolders($chainContent);
$envPlaceHolderMap = [];
$missingEnvironmentPlaceHolders = [];
foreach ($environmentPlaceHolders as $envPlaceHolder) {
if (!getenv($envPlaceHolder)) {
$missingEnvironmentPlaceHolders[$envPlaceHolder] = sprintf('export %s=%s_VALUE', $envPlaceHolder, strtoupper($envPlaceHolder));
continue;
}
$envPlaceHolderMap[$envPlaceHolder] = getenv($envPlaceHolder);
}
if ($missingEnvironmentPlaceHolders) {
$io->error(sprintf($this->trans('commands.chain.messages.missing-environment-placeholders'), implode(', ', array_keys($missingEnvironmentPlaceHolders))));
$io->info($this->trans('commands.chain.messages.set-environment-placeholders'));
$io->block(array_values($missingEnvironmentPlaceHolders));
return 1;
}
$envPlaceHolderData = new ArrayDataSource($envPlaceHolderMap);
$placeholderResolver = new RegexPlaceholderResolver($envPlaceHolderData, '${{', '}}');
$chainContent = $placeholderResolver->resolvePlaceholder($chainContent);
$inlinePlaceHolders = $this->extractInlinePlaceHolders($chainContent);
$inlinePlaceHoldersReplacements = [];
foreach ($inlinePlaceHolders as $key => $inlinePlaceHolder) {
if (strpos($inlinePlaceHolder, '|') > 0) {
$placeholderParts = explode('|', $inlinePlaceHolder);
$inlinePlaceHoldersReplacements[] = $placeholderParts[0];
continue;
}
$inlinePlaceHoldersReplacements[] = $inlinePlaceHolder;
}
$chainContent = str_replace($inlinePlaceHolders, $inlinePlaceHoldersReplacements, $chainContent);
$inlinePlaceHolders = $inlinePlaceHoldersReplacements;
$inlinePlaceHolderMap = [];
foreach ($placeholder as $key => $placeholderItem) {
$inlinePlaceHolderMap = array_merge($inlinePlaceHolderMap, $placeholderItem);
}
$missingInlinePlaceHolders = [];
foreach ($inlinePlaceHolders as $inlinePlaceHolder) {
if (!array_key_exists($inlinePlaceHolder, $inlinePlaceHolderMap)) {
$missingInlinePlaceHolders[$inlinePlaceHolder] = sprintf('--placeholder="%s:%s_VALUE"', $inlinePlaceHolder, strtoupper($inlinePlaceHolder));
}
}
if ($missingInlinePlaceHolders) {
$io->error(sprintf($this->trans('commands.chain.messages.missing-inline-placeholders'), implode(', ', array_keys($missingInlinePlaceHolders))));
$io->info($this->trans('commands.chain.messages.set-inline-placeholders'));
$io->block(array_values($missingInlinePlaceHolders));
return 1;
}
$inlinePlaceHolderData = new ArrayDataSource($inlinePlaceHolderMap);
$placeholderResolver = new RegexPlaceholderResolver($inlinePlaceHolderData, '%{{', '}}');
$chainContent = $placeholderResolver->resolvePlaceholder($chainContent);
$parser = new Parser();
$configData = $parser->parse($chainContent);
$commands = [];
if (array_key_exists('commands', $configData)) {
$commands = $configData['commands'];
}
foreach ($commands as $command) {
$moduleInputs = [];
$arguments = !empty($command['arguments']) ? $command['arguments'] : [];
$options = !empty($command['options']) ? $command['options'] : [];
foreach ($arguments as $key => $value) {
$moduleInputs[$key] = is_null($value) ? '' : $value;
}
foreach ($options as $key => $value) {
$moduleInputs['--' . $key] = is_null($value) ? '' : $value;
}
$parameterOptions = $input->getOptions();
unset($parameterOptions['file']);
foreach ($parameterOptions as $key => $value) {
if ($value === true) {
$moduleInputs['--' . $key] = true;
}
}
$this->chainQueue->addCommand($command['command'], $moduleInputs, $interactive, $learning);
}
return 0;
//.........这里部分代码省略.........