/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $application = $this->getApplication(); $drupal = $this->getDrupalHelper(); // Provide drupal version if it's installed $drupalVersion = $this->trans('commands.site.status.messages.not_installed'); if ($drupal->isInstalled()) { $drupalVersion = sprintf($this->trans('commands.site.status.messages.current_version'), $this->getSite()->getDrupalVersion()); } $aboutTitle = sprintf('%s (%s) | Supports Drupal (%s) | %s', $this->trans('commands.site.status.messages.console'), $application->getVersion(), $application::DRUPAL_SUPPORTED_VERSION, $drupalVersion); $io->setDecorated(false); $io->title($aboutTitle); $io->setDecorated(true); $commands = ['init' => [$this->trans('commands.init.description'), 'drupal init --override'], 'quick-start' => [$this->trans('commands.common.messages.quick-start'), 'drupal chain --file=~/.console/chain/quick-start.yml'], 'site-new' => [$this->trans('commands.site.new.description'), sprintf('drupal site:new drupal8.dev %s', $application::DRUPAL_SUPPORTED_VERSION)], 'site-install' => [$this->trans('commands.site.install.description'), sprintf('drupal site:install')], 'links' => [$this->trans('commands.list.description'), 'drupal list']]; foreach ($commands as $command => $commandInfo) { $io->writeln($commandInfo[0]); $io->newLine(); $io->comment(sprintf(' %s', $commandInfo[1])); $io->newLine(); } $io->setDecorated(false); $io->section($this->trans('commands.self-update.description')); $io->setDecorated(true); $io->comment(' drupal self-update'); $io->newLine(); }
protected function themeDetail(DrupalStyle $io, $themeId) { $theme = null; $themes = $this->getThemeHandler()->rebuildThemeData(); if (isset($themes[$themeId])) { $theme = $themes[$themeId]; } else { foreach ($themes as $themeAvailableId => $themeAvailable) { if ($themeAvailable->info['name'] == $themeId) { $themeId = $themeAvailableId; $theme = $themeAvailable; break; } } } if ($theme) { $theme = $themes[$themeId]; $status = $this->getThemeStatus($themeId); $io->info($theme->info['name']); $io->comment(sprintf('%s : ', $this->trans('commands.theme.debug.messages.status')), false); $io->writeln($status); $io->comment(sprintf('%s : ', $this->trans('commands.theme.debug.messages.version')), false); $io->writeln($theme->info['version']); $io->comment($this->trans('commands.theme.debug.messages.regions')); $tableRows = $this->addThemeAttributes($theme->info['regions'], $tableRows); $io->table([], $tableRows); } else { $io->error(sprintf($this->trans('commands.theme.debug.messages.invalid-theme'), $themeId)); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $this->get('site')->loadLegacyFile('/core/includes/utility.inc'); $validators = $this->getApplication()->getValidator(); // Get the --cache option and make validation $cache = $input->getArgument('cache'); $validated_cache = $validators->validateCache($cache); if (!$validated_cache) { $io->error(sprintf($this->trans('commands.cache.rebuild.messages.invalid_cache'), $cache)); return; } // Start rebuilding cache $io->newLine(); $io->comment($this->trans('commands.cache.rebuild.messages.rebuild')); // Get data needed to rebuild cache $kernelHelper = $this->getApplication()->getKernelHelper(); $classLoader = $kernelHelper->getClassLoader(); $request = $kernelHelper->getRequest(); // Check cache to rebuild if ($cache === 'all') { // If cache is all, then clear all caches drupal_rebuild($classLoader, $request); } else { // Else, clear the selected cache $caches = $validators->getCaches(); $caches[$cache]->deleteAll(); } $io->success($this->trans('commands.cache.rebuild.messages.completed')); }
protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $environment = $input->getArgument('environment'); $loadedConfigurations = []; if (in_array($environment, array('dev', 'prod'))) { $loadedConfigurations = $this->loadConfigurations($environment); } else { $io->error($this->trans('commands.site.mode.messages.invalid-env')); } $configurationOverrideResult = $this->overrideConfigurations($loadedConfigurations['configurations']); foreach ($configurationOverrideResult as $configName => $result) { $io->info($this->trans('commands.site.mode.messages.configuration') . ':', false); $io->comment($configName); $tableHeader = [$this->trans('commands.site.mode.messages.configuration-key'), $this->trans('commands.site.mode.messages.original'), $this->trans('commands.site.mode.messages.updated')]; $io->table($tableHeader, $result); } $servicesOverrideResult = $this->overrideServices($loadedConfigurations['services'], $io); if (!empty($servicesOverrideResult)) { $io->info($this->trans('commands.site.mode.messages.new-services-settings')); $tableHeaders = [$this->trans('commands.site.mode.messages.service'), $this->trans('commands.site.mode.messages.service-parameter'), $this->trans('commands.site.mode.messages.service-value')]; $io->table($tableHeaders, $servicesOverrideResult); } $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']); }
/** * @param \Drupal\Console\Style\DrupalStyle $io * @param $view_id * @return bool */ private function viewDetail(DrupalStyle $io, $view_id) { $entity_manager = $this->getEntityManager(); $view = $entity_manager->getStorage('view')->load($view_id); if (empty($view)) { $io->error(sprintf($this->trans('commands.views.debug.messages.not-found'), $view_id)); return false; } $configuration = array(); $configuration[] = [$this->trans('commands.views.debug.messages.view-id'), $view->get('id')]; $configuration[] = [$this->trans('commands.views.debug.messages.view-name'), (string) $view->get('label')]; $configuration[] = [$this->trans('commands.views.debug.messages.tag'), $view->get('tag')]; $configuration[] = [$this->trans('commands.views.debug.messages.status'), $view->status() ? $this->trans('commands.common.status.enabled') : $this->trans('commands.common.status.disabled')]; $configuration[] = [$this->trans('commands.views.debug.messages.description'), $view->get('description')]; $io->comment($view_id); $io->table([], $configuration); $tableHeader = [$this->trans('commands.views.debug.messages.display-id'), $this->trans('commands.views.debug.messages.display-name'), $this->trans('commands.views.debug.messages.display-description'), $this->trans('commands.views.debug.messages.display-paths')]; $displays = $this->viewDisplayList($view); $io->info(sprintf($this->trans('commands.views.debug.messages.display-list'), $view_id)); $tableRows = []; foreach ($displays as $display_id => $display) { $tableRows[] = [$display_id, $display['name'], $display['description'], $this->viewDisplayPaths($view, $display_id)]; } $io->table($tableHeader, $tableRows, 'compact'); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $nestedArray = $this->getNestedArrayHelper(); $application = $this->getApplication(); $config = $application->getConfig(); $configApplication = $config->get('application'); unset($configApplication['autowire']); unset($configApplication['languages']); unset($configApplication['aliases']); unset($configApplication['default']); $configApplicationFlatten = []; $keyFlatten = ''; $nestedArray->yamlFlattenArray($configApplication, $configApplicationFlatten, $keyFlatten); $tableHeader = [$this->trans('commands.settings.debug.messages.config-key'), $this->trans('commands.settings.debug.messages.config-value')]; $tableRows = []; foreach ($configApplicationFlatten as $yamlKey => $yamlValue) { $tableRows[] = [$yamlKey, $yamlValue]; } $io->newLine(); $io->info(sprintf('%s :', $this->trans('commands.settings.debug.messages.config-file')), false); $io->comment(sprintf('%s/.console/config.yml', $config->getUserHomeDir()), true); $io->newLine(); $io->table($tableHeader, $tableRows, 'compact'); }
private function restDetail(DrupalStyle $io, $resource_id) { $config = $this->getRestDrupalConfig(); $resourcePluginManager = $this->getPluginManagerRest(); $plugin = $resourcePluginManager->getInstance(array('id' => $resource_id)); if (empty($plugin)) { $io->error(sprintf($this->trans('commands.rest.debug.messages.not-found'), $resource_id)); return false; } $resource = $plugin->getPluginDefinition(); $configuration = []; $configuration[] = [$this->trans('commands.rest.debug.messages.id'), $resource['id']]; $configuration[] = [$this->trans('commands.rest.debug.messages.label'), (string) $resource['label']]; $configuration[] = [$this->trans('commands.rest.debug.messages.canonical_url'), $resource['uri_paths']['canonical']]; $configuration[] = [$this->trans('commands.rest.debug.messages.status'), isset($config[$resource['id']]) ? $this->trans('commands.rest.debug.messages.enabled') : $this->trans('commands.rest.debug.messages.disabled')]; $configuration[] = [$this->trans('commands.rest.debug.messages.provider', $resource['provider'])]; $io->comment($resource_id); $io->newLine(); $io->table([], $configuration, 'compact'); $tableHeader = [$this->trans('commands.rest.debug.messages.rest-state'), $this->trans('commands.rest.debug.messages.supported-formats'), $this->trans('commands.rest.debug.messages.supported_auth')]; $tableRows = []; foreach ($config[$resource['id']] as $method => $settings) { $tableRows[] = [$method, implode(', ', $settings['supported_formats']), implode(', ', $settings['supported_auth'])]; } $io->table($tableHeader, $tableRows); }
/** * {@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; }
protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $io->newLine(); $io->comment($this->trans('commands.router.rebuild.messages.rebuilding')); $this->routerBuilder->rebuild(); $io->success($this->trans('commands.router.rebuild.messages.completed')); }
protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $image_handler = $this->getService('entity_type.manager')->getStorage('image_style'); $io->newLine(); $io->comment($this->trans('commands.image.styles.debug.messages.styles-list')); if ($image_handler) { $this->imageStyleList($io, $image_handler); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $imageStyle = $this->entityTypeManager->getStorage('image_style'); $io->newLine(); $io->comment($this->trans('commands.image.styles.debug.messages.styles-list')); if ($imageStyle) { $this->imageStyleList($io, $imageStyle); } return 0; }
/** * @param \Drupal\Console\Style\DrupalStyle $io * @param $project * @return string */ public function releasesQuestion(DrupalStyle $io, $project) { $commandKey = str_replace(':', '.', $this->getName()); $io->comment(sprintf($this->trans('commands.' . $commandKey . '.messages.getting-releases'), implode(',', array($project)))); $releases = $this->getDrupalApi()->getProjectReleases($project, 15); if (!$releases) { $io->error(sprintf($this->trans('commands.' . $commandKey . '.messages.no-releases'), implode(',', array($project)))); return null; } $version = $io->choice($this->trans('commands.' . $commandKey . '.messages.select-release'), $releases); return $version; }
/** * {@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; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $settingKeys = array_keys($this->settings->getAll()); $io->newLine(); $io->info($this->trans('commands.config.settings.debug.messages.current')); $io->newLine(); foreach ($settingKeys as $settingKey) { $io->comment($settingKey, false); $io->simple(Yaml::encode($this->settings->get($settingKey))); } $io->newLine(); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $settings = $this->getSettings(); $settingKeys = array_keys($settings->getAll()); $dumper = new Dumper(); $io->newLine(); $io->info($this->trans('commands.settings.debug.messages.current')); $io->newLine(); foreach ($settingKeys as $settingKey) { $io->comment($settingKey, false); $io->simple($dumper->dump($settings->get($settingKey), 10)); } $io->newLine(); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $files = $this->getChainFiles(); foreach ($files as $directory => $chainFiles) { $io->info($this->trans('commands.chain.debug.messages.directory'), false); $io->comment($directory); $tableHeader = [$this->trans('commands.chain.debug.messages.file')]; $tableRows = []; foreach ($chainFiles as $file) { $tableRows[] = $file; } $io->table($tableHeader, $tableRows); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $group = $input->getArgument('group'); if (!$group) { $groups = $this->getAllLibraries(); $tableHeader = [$this->trans('commands.libraries.debug.messages.name')]; $io->table($tableHeader, $groups, 'compact'); } else { $librariesData = $this->libraryDiscovery->getLibrariesByExtension($group); foreach ($librariesData as $key => $libraries) { $io->comment($key); $io->writeln(Yaml::encode($libraries)); } } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $group = $input->getArgument('group'); if (!$group) { $groups = $this->getAllBreakpoints(); $tableHeader = [$this->trans('commands.breakpoints.debug.messages.name')]; $io->table($tableHeader, $groups, 'compact'); } else { $breakPointData = $this->getBreakpointByName($group); foreach ($breakPointData as $key => $breakPoint) { $io->comment($key); $io->writeln(Yaml::encode($breakPoint)); } } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $configName = $input->getArgument('name'); $key = $input->getArgument('key'); $value = $input->getArgument('value'); $config = $this->getDrupalService('config.factory')->getEditable($configName); $configurationOverrideResult = $this->overrideConfiguration($config, $key, $value); $config->save(); $io->info($this->trans('commands.config.override.messages.configuration'), false); $io->comment($configName); $tableHeader = [$this->trans('commands.config.override.messages.configuration-key'), $this->trans('commands.config.override.messages.original'), $this->trans('commands.config.override.messages.updated')]; $tableRows = $configurationOverrideResult; $io->table($tableHeader, $tableRows); $config->save(); }
/** * {@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; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $config = $this->getApplication()->getConfig(); $directories = [$config->getUserHomeDir() . DIRECTORY_SEPARATOR . '.console' . DIRECTORY_SEPARATOR . 'chain']; foreach ($directories as $directory) { $io->info($this->trans('commands.chain.debug.messages.directory'), false); $io->comment($directory); $finder = new Finder(); $finder->files()->name('*.yml')->in($directory); $tableHeader = [$this->trans('commands.chain.debug.messages.file')]; $tableRows = []; foreach ($finder as $chain) { $tableRows[] = $chain->getBasename(); } $io->table($tableHeader, $tableRows); } }
private function testDetail(DrupalStyle $io, $test_class) { $testingGroups = $this->getTestDiscovery()->getTestClasses(null); $testDetails = null; foreach ($testingGroups as $testing_group => $tests) { foreach ($tests as $key => $test) { if ($test['name'] == $test_class) { $testDetails = $test; break; } } if ($testDetails !== null) { break; } } $class = null; if ($testDetails) { $class = new \ReflectionClass($test['name']); if (is_subclass_of($testDetails['name'], 'PHPUnit_Framework_TestCase')) { $testDetails['type'] = 'phpunit'; } else { $testDetails = $this->getTestDiscovery()->getTestInfo($testDetails['name']); $testDetails['type'] = 'simpletest'; } $io->comment($testDetails['name']); $testInfo = []; foreach ($testDetails as $key => $value) { $testInfo[] = [$key, $value]; } $io->table([], $testInfo); if ($class) { $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC); $io->info($this->trans('commands.test.debug.messages.methods')); foreach ($methods as $method) { if ($method->class == $testDetails['name'] && strpos($method->name, 'test') === 0) { $io->simple($method->name); } } } } else { $io->error($this->trans('commands.test.debug.messages.not-found')); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $io->newLine(); $io->comment($this->trans('commands.node.access.rebuild.messages.rebuild')); $batch = $input->getOption('batch'); try { node_access_rebuild($batch); } catch (\Exception $e) { $io->error($e->getMessage()); return; } $needs_rebuild = $this->getState()->get('node.node_access_needs_rebuild') ?: false; if ($needs_rebuild) { $io->warning($this->trans('commands.node.access.rebuild.messages.failed')); } else { $io->success($this->trans('commands.node.access.rebuild.messages.completed')); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $cache = $input->getArgument('cache'); $this->site->loadLegacyFile('/core/includes/utility.inc'); if ($cache && !$this->drupalApi->isValidCache($cache)) { $io->error(sprintf($this->trans('commands.cache.rebuild.messages.invalid_cache'), $cache)); return 1; } $io->newLine(); $io->comment($this->trans('commands.cache.rebuild.messages.rebuild')); if ($cache === 'all') { drupal_rebuild($this->classLoader, $this->requestStack->getCurrentRequest()); } else { $caches = $this->drupalApi->getCaches(); $caches[$cache]->deleteAll(); } $io->success($this->trans('commands.cache.rebuild.messages.completed')); return 0; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $module = $input->getArgument('module'); $unInstalledDependencies = $this->calculateDependencies((array) $module); if (!$unInstalledDependencies) { $io->warning($this->trans('commands.module.install.dependencies.messages.no-depencies')); return 0; } try { $io->comment(sprintf($this->trans('commands.module.install.dependencies.messages.installing'), implode(', ', $unInstalledModules))); $moduleInstaller = $this->getDrupalService('module_installer'); drupal_static_reset('system_rebuild_module_data'); $moduleInstaller->install($unInstalledDependencies, true); $io->success(sprintf($this->trans('commands.module.install.dependencies.messages.success'), implode(', ', $unInstalledDependencies))); } catch (\Exception $e) { $io->error($e->getMessage()); return 1; } $this->get('chain_queue')->addCommand('cache:rebuild', ['cache' => 'all']); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); // Retrieve whether detailed option has been selected. $detailedOutput = $input->getOption('detailed'); // Retrieve whether an entity type has been specified. $entityTypeOption = $input->getOption('entity'); // Retrieve whether a specific bundle type has been specified. $bundleTypeOption = $input->getOption('bundle'); $entityList = $this->entityTypeManager->getDefinitions(); $allFields = $this->entityFieldManager->getFieldMap(); // Set a flag so we can error if a specific entity type selected but not found. $entityTypeOptionFound = false; // Set a flag so we can error if a specific bundle type selected but not found. $bundleTypeOptionFound = false; // Let's count the fields found so we can display a message if none found. $fieldCounter = 0; foreach ($entityList as $entityTypeId => $entityValue) { // If the Entity has bundleEntityType set we grab it. $bundleEntityType = $entityValue->get('bundle_entity_type'); // Check to see if the entity has any bundle before continuing. if (!empty($bundleEntityType)) { $bundleTypes = $this->entityTypeManager->getStorage($bundleEntityType)->loadMultiple(); // If a specific entity type has been selected and this is it then we continue else we skip. if ((!empty($entityTypeOption) && $entityTypeOption == $entityTypeId) | empty($entityTypeOption)) { // Store the fact that we found the entity type specified so we can error if not found. $entityTypeOptionFound = true; // Get the entity type label. $bundleParent = $entityValue->get('label'); // Using counter to know whether to output header. $bundleTypeCounter = 0; foreach ($bundleTypes as $bundleType) { // If a specific bundle type has been selected and this is it then we continue else we skip. if ((!empty($bundleTypeOption) && $bundleTypeOption == $bundleType->id()) | empty($bundleTypeOption)) { // Store the fact that we found the bundle type specified so we can error if not found. $bundleTypeOptionFound = true; // Increase the bundle type counter so we know whether to output header. $bundleTypeCounter++; if ($bundleTypeCounter == 1) { // Output the Parent Entity label if we haven't already. if ($detailedOutput) { // If detailed output then display the id as well. $io->info(strtoupper($bundleParent) . ' (' . $entityTypeId . '):'); } else { // otherwise just display the label for normal output. $io->info(strtoupper($bundleParent . ':')); } $io->newLine(); } // Load in the entityType fields. $fields = $this->getBundleFields($entityTypeId, $bundleType->id()); foreach ($fields as $field => $fieldArray) { // We found a field so increase the field counter. $fieldCounter++; // Get the related / used in bundles from the field. $relatedBundles = ""; $relatedBundlesArray = $allFields[$entityTypeId][$field]['bundles']; // Turn those related / used in bundles array into a string. foreach ($relatedBundlesArray as $relatedBundlesValue) { if ($bundleTypes[$relatedBundlesValue]->id() != $bundleType->id()) { if (!empty($relatedBundles)) { $relatedBundles .= ', ' . $bundleTypes[$relatedBundlesValue]->label(); } else { $relatedBundles = $bundleTypes[$relatedBundlesValue]->label(); } } } // Build out our table for the fields. $tableRows[] = $detailedOutput ? [$fieldArray->get('label'), $fieldArray->get('field_type'), $fieldArray->get('description'), $relatedBundles] : [$fieldArray->get('label'), $fieldArray->get('field_type'), $relatedBundles]; // Clear the related bundles ready for the next field. unset($relatedBundles); } // If detailed output then display bundle id and description. if ($detailedOutput) { // Output the bundle label and id. $io->info($bundleType->label() . ' (' . $bundleType->id() . ')'); $io->info(strip_tags($bundleType->get('description'))); } else { // Else just output the bundle label. $io->info($bundleType->label()); } // Fill out our table header. // If no rows exist for the fields then we display a no results message. if (!empty($tableRows)) { $tableHeader = $detailedOutput ? [$this->trans('commands.field.info.table.header-name'), $this->trans('commands.field.info.table.header-type'), $this->trans('commands.field.info.table.header-desc'), $this->trans('commands.field.info.table.header-usage')] : [$this->trans('commands.field.info.table.header-name'), $this->trans('commands.field.info.table.header-type'), $this->trans('commands.field.info.table.header-usage')]; $io->table($tableHeader, $tableRows); } else { $io->comment($this->trans('commands.field.info.messages.fields-none') . ' ' . $this->trans('commands.field.info.messages.in-bundle-type') . " '" . $bundleType->label() . "'"); } // Clear out the rows & headers arrays to start fresh. unset($tableHeader, $tableRows); // Create some space so the output looks nice. $io->newLine(); } } } } } // If entity type was specified but not found then display error message. if (!empty($entityTypeOption)) { if (!$entityTypeOptionFound) { $io->comment($this->trans('commands.field.info.messages.entity-type') . ' ' . $entityTypeOption . ' ' . $this->trans('commands.field.info.messages.not-found')); } elseif (!empty($bundleTypeOption) && !$bundleTypeOptionFound) { // If specified entity type found and bundle type specified but not found then display error message. $io->comment($this->trans('commands.field.info.messages.bundle-type') . ' ' . $bundleTypeOption . ' ' . $this->trans('commands.field.info.messages.not-found') . ' ' . $this->trans('commands.field.info.messages.in-entity-type') . ' ' . $entityTypeOption); } } elseif (!empty($bundleTypeOption) && !$bundleTypeOptionFound) { // If specified bundle type not found then display error message. $io->comment($this->trans('commands.field.info.messages.bundle-type') . ' ' . $bundleTypeOption . ' ' . $this->trans('commands.field.info.messages.not-found')); } elseif ($fieldCounter == 0) { // If no fields found then display appropriate message. $io->comment($this->trans('commands.field.info.messages.fields-none')); } return 0; }
/** * {@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; } }
/** * @param \Drupal\Console\Style\DrupalStyle $io * @param string $project * @param bool $latest * @param bool $stable * @return string */ public function releasesQuestion(DrupalStyle $io, $project, $latest = false, $stable = false) { $commandKey = str_replace(':', '.', $this->getName()); $io->comment(sprintf($this->trans('commands.' . $commandKey . '.messages.getting-releases'), implode(',', array($project)))); $releases = $this->drupalApi->getProjectReleases($this->httpClient, $project, $latest ? 1 : 15, $stable); if (!$releases) { $io->error(sprintf($this->trans('commands.' . $commandKey . '.messages.no-releases'), implode(',', array($project)))); return null; } if ($latest) { return $releases[0]; } $version = $io->choice($this->trans('commands.' . $commandKey . '.messages.select-release'), $releases); return $version; }
protected function showDataAsTable(DrupalStyle $io, $siteData) { if (empty($siteData)) { return []; } $io->newLine(); foreach ($this->groups as $group) { $tableRows = []; $groupData = $siteData[$group]; $io->comment($this->trans('commands.site.status.messages.' . $group)); foreach ($groupData as $key => $item) { $tableRows[] = [$key, $item]; } $io->table([], $tableRows, 'compact'); } }
/** * @param DrupalStyle $io * @param string $file * @param int $index */ private function showFile(DrupalStyle $io, $file, $index) { $io->info(sprintf('%s -', $index), false); $io->comment($file, false); $io->newLine(); }