本文整理汇总了PHP中Drupal\Console\Style\DrupalStyle::commentBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP DrupalStyle::commentBlock方法的具体用法?PHP DrupalStyle::commentBlock怎么用?PHP DrupalStyle::commentBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Console\Style\DrupalStyle
的用法示例。
在下文中一共展示了DrupalStyle::commentBlock方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
$address = $input->getArgument('address');
if (false === strpos($address, ':')) {
$address = sprintf('%s:8088', $address);
}
$finder = new PhpExecutableFinder();
if (false === ($binary = $finder->find())) {
$io->error($this->trans('commands.server.errors.binary'));
return;
}
$router = $this->getRouterPath();
$cli = sprintf('%s %s %s %s', $binary, '-S', $address, $router);
if ($learning) {
$io->commentBlock($cli);
}
$io->success(sprintf($this->trans('commands.server.messages.executing'), $binary));
$processBuilder = new ProcessBuilder(explode(' ', $cli));
$process = $processBuilder->getProcess();
$process->setWorkingDirectory($this->get('site')->getRoot());
$process->setTty('true');
$process->run();
if (!$process->isSuccessful()) {
$io->error($process->getErrorOutput());
}
}
示例2: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
$address = $this->validatePort($input->getArgument('address'));
$finder = new PhpExecutableFinder();
if (false === ($binary = $finder->find())) {
$io->error($this->trans('commands.server.errors.binary'));
return;
}
$router = $this->getRouterPath();
$cli = sprintf('%s %s %s %s', $binary, '-S', $address, $router);
if ($learning) {
$io->commentBlock($cli);
}
$io->success(sprintf($this->trans('commands.server.messages.executing'), $binary));
$processBuilder = new ProcessBuilder(explode(' ', $cli));
$process = $processBuilder->getProcess();
$process->setWorkingDirectory($this->appRoot);
if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
$process->setTty('true');
} else {
$process->setTimeout(null);
}
$process->run();
if (!$process->isSuccessful()) {
$io->error($process->getErrorOutput());
}
}
示例3: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$requirementChecker = $this->get('requirement_checker');
$checks = $requirementChecker->getCheckResult();
if (!$checks) {
$phpCheckFile = $this->getApplication()->getConfig()->getUserHomeDir() . '/.console/phpcheck.yml';
if (!file_exists($phpCheckFile)) {
$phpCheckFile = $this->getApplication()->getDirectoryRoot() . 'config/dist/phpcheck.yml';
}
$requirementChecker->validate($phpCheckFile);
$checks = $requirementChecker->validate($phpCheckFile);
}
if (!$checks['php']['valid']) {
$io->error(sprintf($this->trans('commands.check.messages.php_invalid'), $checks['php']['current'], $checks['php']['required']));
}
if ($extensions = $checks['extensions']['required']['missing']) {
foreach ($extensions as $extension) {
$io->error(sprintf($this->trans('commands.check.messages.extension_missing'), $extension));
}
}
if ($extensions = $checks['extensions']['recommended']['missing']) {
foreach ($extensions as $extension) {
$io->commentBlock(sprintf($this->trans('commands.check.messages.extension_recommended'), $extension));
}
}
if ($configurations = $checks['configurations']['required']['missing']) {
foreach ($configurations as $configuration) {
$io->error(sprintf($this->trans('commands.check.messages.configuration_missing'), $configuration));
}
}
if ($configurations = $checks['configurations']['required']['overwritten']) {
foreach ($configurations as $configuration => $overwritten) {
$io->commentBlock(sprintf($this->trans('commands.check.messages.configuration_overwritten'), $configuration, $overwritten));
}
}
if ($requirementChecker->isValid() && !$requirementChecker->isOverwritten()) {
$io->success($this->trans('commands.check.messages.success'));
$this->get('chain_queue')->addCommand('settings:set', ['setting-name' => 'checked', 'setting-value' => 'true', '--quiet']);
}
return $requirementChecker->isValid();
}
示例4: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$directory = $input->getArgument('directory');
$version = $input->getArgument('version');
$latest = $input->getOption('latest');
$composer = $input->getOption('composer');
if (!$directory) {
$io->error($this->trans('commands.site.new.messages.missing-directory'));
return 1;
}
if ($composer) {
if (!$version) {
$version = '8.x-dev';
}
$io->newLine();
$io->comment(sprintf($this->trans('commands.site.new.messages.executing'), 'drupal', $version));
$command = sprintf('composer create-project %s:%s %s --no-interaction', 'drupal-composer/drupal-project', $version, $directory);
$io->commentBlock($command);
$shellProcess = $this->get('shell_process');
if ($shellProcess->exec($command)) {
$io->success(sprintf($this->trans('commands.site.new.messages.composer'), $version, $directory));
return 0;
} else {
return 1;
}
}
if (!$version && $latest) {
$version = current($this->getApplication()->getDrupalApi()->getProjectReleases('drupal', 1, true));
}
if (!$version) {
$io->error('Missing version');
return 1;
}
$projectPath = $this->downloadProject($io, 'drupal', $version, 'core');
$downloadPath = sprintf('%sdrupal-%s', $projectPath, $version);
if ($this->isAbsolutePath($directory)) {
$copyPath = $directory;
} else {
$copyPath = sprintf('%s%s', $projectPath, $directory);
}
try {
$fileSystem = new Filesystem();
$fileSystem->rename($downloadPath, $copyPath);
} catch (IOExceptionInterface $e) {
$io->commentBlock(sprintf($this->trans('commands.site.new.messages.downloaded'), $version, $downloadPath));
$io->error(sprintf($this->trans('commands.site.new.messages.error-copying'), $e->getPath()));
return 1;
}
$io->success(sprintf($this->trans('commands.site.new.messages.downloaded'), $version, $copyPath));
return 0;
}
示例5: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$requirementChecker = $this->getContainerHelper()->get('requirement_checker');
$checks = $requirementChecker->getCheckResult();
if (!$checks) {
$checks = $requirementChecker->validate($this->getApplication()->getDirectoryRoot() . '/requirements.yml');
}
if (!$checks['php']['valid']) {
$io->error(sprintf($this->trans('commands.settings.check.messages.php_invalid'), $checks['php']['current'], $checks['php']['required']));
}
if ($extensions = $checks['extensions']['required']['missing']) {
foreach ($extensions as $extension) {
$io->error(sprintf($this->trans('commands.settings.check.messages.extension_missing'), $extension));
}
}
if ($extensions = $checks['extensions']['recommended']['missing']) {
foreach ($extensions as $extension) {
$io->commentBlock(sprintf($this->trans('commands.settings.check.messages.extension_recommended'), $extension));
}
}
if ($configurations = $checks['configurations']['required']['missing']) {
foreach ($configurations as $configuration) {
$io->error(sprintf($this->trans('commands.settings.check.messages.configuration_missing'), $configuration));
}
}
if ($configurations = $checks['configurations']['required']['overwritten']) {
foreach ($configurations as $configuration => $overwritten) {
$io->commentBlock(sprintf($this->trans('commands.settings.check.messages.configuration_overwritten'), $configuration, $overwritten));
}
}
if ($requirementChecker->isValid() && !$requirementChecker->isOverwritten()) {
$io->success($this->trans('commands.settings.check.messages.success'));
}
return $requirementChecker->isValid();
}
示例6: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
//Registers namespaces for disabled modules.
$this->getTestDiscovery()->registerTestNamespaces();
$testClass = $input->getArgument('test-class');
$url = $input->getOption('url');
if (!$url) {
$io->error($this->trans('commands.test.run.messages.url-required'));
return;
}
$this->setEnvironment($url);
// Create simpletest test id
$testId = db_insert('simpletest_test_id')->useDefaults(array('test_id'))->execute();
if (is_subclass_of($testClass, 'PHPUnit_Framework_TestCase')) {
$io->info($this->trans('commands.test.run.messages.phpunit-pending'));
return;
} else {
$test = new $testClass($testId);
$io->info($this->trans('commands.test.run.messages.starting-test'));
Timer::start('run-tests');
$test->run();
$end = Timer::stop('run-tests');
$io->simple($this->trans('commands.test.run.messages.test-duration') . ': ' . \Drupal::service('date.formatter')->formatInterval($end['time'] / 1000));
$io->simple($this->trans('commands.test.run.messages.test-pass') . ': ' . $test->results['#pass']);
$io->commentBlock($this->trans('commands.test.run.messages.test-fail') . ': ' . $test->results['#fail']);
$io->commentBlock($this->trans('commands.test.run.messages.test-exception') . ': ' . $test->results['#exception']);
$io->simple($this->trans('commands.test.run.messages.test-debug') . ': ' . $test->results['#debug']);
$this->getModuleHandler()->invokeAll('test_finished', array($test->results));
$io->newLine();
$io->info($this->trans('commands.test.run.messages.test-summary'));
$io->newLine();
$currentClass = null;
$currentGroup = null;
$currentStatus = null;
$messages = $this->simpletestScriptLoadMessagesByTestIds(array($testId));
foreach ($messages as $message) {
if ($currentClass === null || $currentClass != $message->test_class) {
$currentClass = $message->test_class;
$io->comment($message->test_class);
}
if ($currentGroup === null || $currentGroup != $message->message_group) {
$currentGroup = $message->message_group;
}
if ($currentStatus === null || $currentStatus != $message->status) {
$currentStatus = $message->status;
if ($message->status == 'fail') {
$io->error($this->trans('commands.test.run.messages.group') . ':' . $message->message_group . ' ' . $this->trans('commands.test.run.messages.status') . ':' . $message->status);
$io->newLine();
} else {
$io->info($this->trans('commands.test.run.messages.group') . ':' . $message->message_group . ' ' . $this->trans('commands.test.run.messages.status') . ':' . $message->status);
$io->newLine();
}
}
$io->simple($this->trans('commands.test.run.messages.file') . ': ' . str_replace($this->getDrupalHelper()->getRoot(), '', $message->file));
$io->simple($this->trans('commands.test.run.messages.method') . ': ' . $message->function);
$io->simple($this->trans('commands.test.run.messages.line') . ': ' . $message->line);
$io->simple($this->trans('commands.test.run.messages.message') . ': ' . $message->message);
$io->newLine();
}
return;
}
}
示例7: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$type = $input->getArgument('type');
if (!$type) {
$io->error($this->trans('commands.config.delete.errors.type'));
return 1;
}
$name = $input->getArgument('name');
if (!$name) {
$io->error($this->trans('commands.config.delete.errors.name'));
return 1;
}
$configStorage = 'active' === $type ? $this->configStorage : $this->configStorageSync;
if (!$configStorage) {
$io->error($this->trans('commands.config.delete.errors.config-storage'));
return 1;
}
if ('all' === $name) {
$io->commentBlock($this->trans('commands.config.delete.warnings.undo'));
if ($io->confirm($this->trans('commands.config.delete.questions.sure'))) {
if ($configStorage instanceof FileStorage) {
$configStorage->deleteAll();
} else {
foreach ($this->yieldAllConfig() as $name) {
$this->removeConfig($name);
}
}
$io->success($this->trans('commands.config.delete.messages.all'));
return 0;
}
}
if ($configStorage->exists($name)) {
if ($configStorage instanceof FileStorage) {
$configStorage->delete($name);
} else {
$this->removeConfig($name);
}
$io->success(sprintf($this->trans('commands.config.delete.messages.deleted'), $name));
return 0;
}
$message = sprintf($this->trans('commands.config.delete.errors.not-exists'), $name);
$io->error($message);
return 1;
}
示例8: overrideServices
protected function overrideServices($servicesSettings, DrupalStyle $io)
{
$directory = sprintf('%s/%s', $this->appRoot, \Drupal::service('site.path'));
$settingsServicesFile = $directory . '/services.yml';
if (!file_exists($settingsServicesFile)) {
// Copying default services
$defaultServicesFile = $this->appRoot . '/sites/default/default.services.yml';
if (!copy($defaultServicesFile, $settingsServicesFile)) {
$io->error(sprintf('%s: %s/services.yml', $this->trans('commands.site.mode.messages.error-copying-file'), $directory));
return [];
}
}
$yaml = new Yaml();
$services = $yaml->parse(file_get_contents($settingsServicesFile));
$result = [];
foreach ($servicesSettings as $service => $parameters) {
foreach ($parameters as $parameter => $value) {
$services['parameters'][$service][$parameter] = $value;
// Set values for output
$result[$parameter]['service'] = $service;
$result[$parameter]['parameter'] = $parameter;
if (is_bool($value)) {
$value = $value ? 'true' : 'false';
}
$result[$parameter]['value'] = $value;
}
}
if (file_put_contents($settingsServicesFile, $yaml->dump($services))) {
$io->commentBlock(sprintf($this->trans('commands.site.mode.messages.services-file-overwritten'), $settingsServicesFile));
} else {
$io->error(sprintf('%s : %s/services.yml', $this->trans('commands.site.mode.messages.error-writing-file'), $directory));
return [];
}
sort($result);
return $result;
}