Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $event_dispatcher = $this->getDrupalService('event_dispatcher');
     $events = array_keys($event_dispatcher->getListeners());
     $event = $input->getArgument('event');
     if ($event) {
         if (!in_array($event, $events)) {
             throw new \Exception(sprintf($this->trans('commands.event.debug.messages.no-events'), $module));
         }
         $dispacher = $event_dispatcher->getListeners($event);
         $listeners = [];
         foreach ($dispacher as $key => $value) {
             $reflection = new \ReflectionClass(get_class($value[0]));
             $listeners[] = [$reflection->getName(), $value[1]];
         }
         $tableHeader = [$this->trans('commands.event.debug.messages.class'), $this->trans('commands.event.debug.messages.method')];
         $tableRows = [];
         foreach ($listeners as $key => $element) {
             $tableRows[] = ['class' => $element['0'], 'method' => $element['1']];
         }
         $io->table($tableHeader, $tableRows);
         return 0;
     }
     $io->table([$this->trans('commands.event.debug.messages.event')], $events);
 }
Exemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $this->get('site')->loadLegacyFile('/core/modules/system/system.module');
     $status = strtolower($input->getOption('status'));
     $type = strtolower($input->getOption('type'));
     $modules = strtolower($input->getArgument('module'));
     if ($modules) {
         $config = $this->getApplication()->getConfig();
         $repo = $config->get('application.composer.repositories.default');
         foreach ($modules as $module) {
             $url = sprintf('%s/packages/drupal/%s.json', $config->get('application.composer.packages.default'), $module);
             try {
                 $data = $this->getApplication()->getHttpClientHelper()->getUrlAsJson($repo . $url);
             } catch (\Exception $e) {
                 $io->error(sprintf($this->trans('commands.module.debug.messages.no-results'), $module));
                 return 1;
             }
             $tableHeader = ['<info>' . $data->package->name . '</info>'];
             $tableRows = [];
             $tableRows[] = [$data->package->description];
             $tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-downloads') . '</comment>', $data->package->downloads->total];
             $tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-monthly') . '</comment>', $data->package->downloads->monthly];
             $tableRows[] = ['<comment>' . $this->trans('commands.module.debug.messages.total-daily') . '</comment>', $data->package->downloads->daily];
             $io->table($tableHeader, $tableRows, 'compact');
         }
         return 0;
     }
     if ($status == 'installed') {
         $status = 1;
     } elseif ($status == 'uninstalled') {
         $status = 0;
     } else {
         $status = -1;
     }
     if ($type == 'core') {
         $type = 'core';
     } elseif ($type == 'no-core') {
         $type = '';
     } else {
         $type = null;
     }
     $tableHeader = [$this->trans('commands.module.debug.messages.id'), $this->trans('commands.module.debug.messages.name'), $this->trans('commands.module.debug.messages.package'), $this->trans('commands.module.debug.messages.version'), $this->trans('commands.module.debug.messages.schema-version'), $this->trans('commands.module.debug.messages.status'), $this->trans('commands.module.debug.messages.origin')];
     $tableRows = [];
     $modules = system_rebuild_module_data();
     foreach ($modules as $module_id => $module) {
         if ($status >= 0 && $status != $module->status) {
             continue;
         }
         if ($type !== null && $type !== $module->origin) {
             continue;
         }
         $module_status = $module->status ? $this->trans('commands.module.debug.messages.installed') : $this->trans('commands.module.debug.messages.uninstalled');
         $module_origin = $module->origin ? $module->origin : 'no core';
         $schema_version = drupal_get_installed_schema_version($module_id) != -1 ? drupal_get_installed_schema_version($module_id) : '';
         $tableRows[] = [$module_id, $module->info['name'], $module->info['package'], $module->info['version'], $schema_version, $module_status, $module_origin];
     }
     $io->table($tableHeader, $tableRows, 'compact');
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $pluginType = $input->getArgument('type');
     $pluginId = $input->getArgument('id');
     // No plugin type specified, show a list of plugin types.
     if (!$pluginType) {
         $tableHeader = [$this->trans('commands.plugin.debug.table-headers.plugin-type-name'), $this->trans('commands.plugin.debug.table-headers.plugin-type-class')];
         $tableRows = [];
         $drupalContainer = $this->getDrupalContainer();
         foreach ($drupalContainer->getServiceIds() as $serviceId) {
             if (strpos($serviceId, 'plugin.manager.') === 0) {
                 $service = $drupalContainer->get($serviceId);
                 $typeName = substr($serviceId, 15);
                 $class = get_class($service);
                 $tableRows[$typeName] = [$typeName, $class];
             }
         }
         ksort($tableRows);
         $io->table($tableHeader, array_values($tableRows));
         return true;
     }
     $service = $this->getDrupalService('plugin.manager.' . $pluginType);
     if (!$service) {
         $io->error(sprintf($this->trans('commands.plugin.debug.errors.plugin-type-not-found'), $pluginType));
         return false;
     }
     // Valid plugin type specified, no ID specified, show list of instances.
     if (!$pluginId) {
         $tableHeader = [$this->trans('commands.plugin.debug.table-headers.plugin-id'), $this->trans('commands.plugin.debug.table-headers.plugin-class')];
         $tableRows = [];
         foreach ($service->getDefinitions() as $definition) {
             $pluginId = $definition['id'];
             $className = $definition['class'];
             $tableRows[$pluginId] = [$pluginId, $className];
         }
         ksort($tableRows);
         $io->table($tableHeader, array_values($tableRows));
         return true;
     }
     // Valid plugin type specified, ID specified, show the definition.
     $definition = $service->getDefinition($pluginId);
     $tableHeader = [$this->trans('commands.plugin.debug.table-headers.definition-key'), $this->trans('commands.plugin.debug.table-headers.definition-value')];
     $tableRows = [];
     foreach ($definition as $key => $value) {
         if (is_object($value) && method_exists($value, '__toString')) {
             $value = (string) $value;
         } elseif (is_array($value) || is_object($value)) {
             $value = Yaml::dump($value);
         } elseif (is_bool($value)) {
             $value = $value ? 'TRUE' : 'FALSE';
         }
         $tableRows[$key] = [$key, $value];
     }
     ksort($tableRows);
     $io->table($tableHeader, array_values($tableRows));
     return true;
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $service = $input->getArgument('service');
     $tableHeader = [];
     if ($service) {
         $tableRows = $this->getServiceDetail($service);
         $io->table($tableHeader, $tableRows, 'compact');
         return 0;
     }
     $tableHeader = [$this->trans('commands.container.debug.messages.service_id'), $this->trans('commands.container.debug.messages.class_name')];
     $tableRows = $this->getServiceList();
     $io->table($tableHeader, $tableRows, 'compact');
 }
Exemplo n.º 5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $this->get('site')->loadLegacyFile('/core/includes/update.inc');
     $this->get('site')->loadLegacyFile('/core/includes/install.inc');
     $updateRegistry = $this->getDrupalService('update.post_update_registry');
     drupal_load_updates();
     update_fix_compatibility();
     $updates = update_get_update_list();
     $postUpdates = $updateRegistry->getPendingUpdateInformation();
     $requirements = update_check_requirements();
     $severity = drupal_requirements_severity($requirements);
     $io->newLine();
     if ($severity == REQUIREMENT_ERROR || $severity == REQUIREMENT_WARNING) {
         $io->info($this->trans('commands.update.debug.messages.requirements-error'));
         $tableHeader = [$this->trans('commands.update.debug.messages.severity'), $this->trans('commands.update.debug.messages.title'), $this->trans('commands.update.debug.messages.value'), $this->trans('commands.update.debug.messages.description')];
         $tableRows = [];
         foreach ($requirements as $requirement) {
             if (isset($requirement['minimum schema']) & in_array($requirement['minimum schema'], array(REQUIREMENT_ERROR, REQUIREMENT_WARNING))) {
                 $tableRows[] = [$requirement['severity'], $requirement['title'], $requirement['value'], $requirement['description']];
             }
         }
         $io->table($tableHeader, $tableRows);
         return;
     }
     if (empty($updates)) {
         $io->info($this->trans('commands.update.debug.messages.no-updates'));
         return;
     }
     $tableHeader = [$this->trans('commands.update.debug.messages.module'), $this->trans('commands.update.debug.messages.update-n'), $this->trans('commands.update.debug.messages.description')];
     $io->info($this->trans('commands.update.debug.messages.module-list'));
     $tableRows = [];
     foreach ($updates as $module => $module_updates) {
         foreach ($module_updates['pending'] as $update_n => $update) {
             list(, $description) = explode($update_n . " - ", $update);
             $tableRows[] = [$module, $update_n, trim($description)];
         }
     }
     $io->table($tableHeader, $tableRows);
     $tableHeader = [$this->trans('commands.update.debug.messages.module'), $this->trans('commands.update.debug.messages.post-update'), $this->trans('commands.update.debug.messages.description')];
     $io->info($this->trans('commands.update.debug.messages.module-list-post-update'));
     $tableRows = [];
     foreach ($postUpdates as $module => $module_updates) {
         foreach ($module_updates['pending'] as $postUpdateFunction => $message) {
             $tableRows[] = [$module, $postUpdateFunction, $message];
         }
     }
     $io->table($tableHeader, $tableRows);
 }
Exemplo n.º 6
0
 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));
     }
 }
Exemplo n.º 7
0
 /**
  * {@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');
 }
Exemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $tableHeader = [$this->trans('commands.queue.debug.messages.queue'), $this->trans('commands.queue.debug.messages.items'), $this->trans('commands.queue.debug.messages.class')];
     $tableBody = $this->listQueues();
     $io->table($tableHeader, $tableBody);
 }
Exemplo n.º 9
0
 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']);
 }
Exemplo n.º 10
0
 protected function getRouteByNames(DrupalStyle $io, $route_name)
 {
     $routes = $this->routeProvider->getRoutesByNames($route_name);
     foreach ($routes as $name => $route) {
         $tableHeader = [$this->trans('commands.router.debug.messages.route'), '<info>' . $name . '</info>'];
         $tableRows = [];
         $tableRows[] = ['<comment>' . $this->trans('commands.router.debug.messages.path') . '</comment>', $route->getPath()];
         $tableRows[] = ['<comment>' . $this->trans('commands.router.debug.messages.defaults') . '</comment>'];
         $attributes = $this->addRouteAttributes($route->getDefaults());
         foreach ($attributes as $attribute) {
             $tableRows[] = $attribute;
         }
         $tableRows[] = ['<comment>' . $this->trans('commands.router.debug.messages.requirements') . '</comment>'];
         $requirements = $this->addRouteAttributes($route->getRequirements());
         foreach ($requirements as $requirement) {
             $tableRows[] = $requirement;
         }
         $tableRows[] = ['<comment>' . $this->trans('commands.router.debug.messages.options') . '</comment>'];
         $options = $this->addRouteAttributes($route->getOptions());
         foreach ($options as $option) {
             $tableRows[] = $option;
         }
         $io->table($tableHeader, $tableRows, 'compact');
     }
 }
Exemplo n.º 11
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $module_handler = $this->getModuleHandler();
     $io->section($this->trans('commands.cron.debug.messages.module-list'));
     $io->table([$this->trans('commands.cron.debug.messages.module')], $module_handler->getImplementations('cron'), 'compact');
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $language = $input->getArgument('language');
     $tableHeader = [$this->trans('commands.locale.translation.status.messages.project'), $this->trans('commands.locale.translation.status.messages.version'), $this->trans('commands.locale.translation.status.messages.local-age'), $this->trans('commands.locale.translation.status.messages.remote-age'), $this->trans('commands.locale.translation.status.messages.info')];
     $languages = locale_translatable_language_list();
     $status = locale_translation_get_status();
     $this->getModuleHandler()->loadInclude('locale', 'compare.inc');
     if (!$languages) {
         $io->info($this->trans('commands.locale.translation.status.messages.no-languages'));
         return;
     } elseif (empty($status)) {
         $io->info($this->trans('commands.locale.translation.status.messages.no-translations'));
         return;
     }
     if ($languages) {
         $projectsStatus = $this->projectsStatus();
         foreach ($projectsStatus as $langcode => $rows) {
             $tableRows = [];
             if ($language != '' && !($language == $langcode || strtolower($language) == strtolower($languages[$langcode]->getName()))) {
                 continue;
             }
             $io->info($languages[$langcode]->getName());
             foreach ($rows as $row) {
                 if ($row[0] == 'drupal') {
                     $row[0] = $this->trans('commands.common.messages.drupal-core');
                 }
                 $tableRows[] = $row;
             }
             $io->table($tableHeader, $tableRows, 'compact');
         }
     }
 }
Exemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $vocabularies = $this->getDrupalApi()->getVocabularies();
     // Validate provided vocabularies
     $vids = $input->getArgument('vocabularies');
     $invalidVids = array_filter(array_map(function ($vid) use($vocabularies) {
         if (!isset($vocabularies[$vid])) {
             return $vid;
         } else {
             return null;
         }
     }, $vids));
     if (!empty($invalidVids)) {
         $io->error(sprintf($this->trans('commands.create.terms.messages.invalid-vocabularies'), implode(',', $invalidVids)));
         return;
     }
     $limit = $input->getOption('limit') ?: 10;
     $nameWords = $input->getOption('name-words') ?: 5;
     $createTerms = $this->getDrupalApi()->getCreateTerms();
     $terms = $createTerms->createTerm($vids, $limit, $nameWords);
     $tableHeader = [$this->trans('commands.create.terms.messages.term-id'), $this->trans('commands.create.terms.messages.vocabulary'), $this->trans('commands.create.terms.messages.name')];
     $io->table($tableHeader, $terms['success']);
     $io->success(sprintf($this->trans('commands.create.terms.messages.created-terms'), $limit));
     return;
 }
Exemplo n.º 14
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $status = $input->getOption('status');
     $type = $input->getOption('type');
     if (strtolower($status) == 'enabled') {
         $status = 1;
     } elseif (strtolower($status) == 'disabled') {
         $status = 0;
     } else {
         $status = -1;
     }
     if (strtolower($type) == 'core') {
         $type = 'core';
     } elseif (strtolower($type) == 'no-core') {
         $type = '';
     } else {
         $type = null;
     }
     $tableHeader = [$this->trans('commands.module.debug.messages.id'), $this->trans('commands.module.debug.messages.name'), $this->trans('commands.module.debug.messages.status'), $this->trans('commands.module.debug.messages.package'), $this->trans('commands.module.debug.messages.schema-version'), $this->trans('commands.module.debug.messages.origin')];
     $tableRows = [];
     $modules = system_rebuild_module_data();
     foreach ($modules as $module_id => $module) {
         if ($status >= 0 && $status != $module->status) {
             continue;
         }
         if ($type !== null && $type !== $module->origin) {
             continue;
         }
         $module_status = $module->status ? $this->trans('commands.module.debug.messages.enabled') : $this->trans('commands.module.debug.messages.disabled');
         $schema_version = drupal_get_installed_schema_version($module_id) != -1 ? drupal_get_installed_schema_version($module_id) : '';
         $tableRows[] = [$module_id, $module->info['name'], $module_status, $module->info['package'], $schema_version, $module->origin];
     }
     $io->table($tableHeader, $tableRows, 'compact');
 }
Exemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $roles = $input->getOption('roles');
     $limit = $input->getOption('limit');
     $entityManager = $this->getEntityManager();
     $userStorage = $entityManager->getStorage('user');
     $systemRoles = $this->getDrupalApi()->getRoles();
     $entityQuery = $this->getEntityQuery();
     $query = $entityQuery->get('user');
     $query->condition('uid', 0, '>');
     $query->sort('uid');
     if ($roles) {
         $query->condition('roles', is_array($roles) ? $roles : [$roles], 'IN');
     }
     if ($limit) {
         $query->range(0, $limit);
     }
     $results = $query->execute();
     $users = $userStorage->loadMultiple($results);
     $tableHeader = [$this->trans('commands.user.debug.messages.user-id'), $this->trans('commands.user.debug.messages.username'), $this->trans('commands.user.debug.messages.roles'), $this->trans('commands.user.debug.messages.status')];
     $tableRows = [];
     foreach ($users as $userId => $user) {
         $userRoles = [];
         foreach ($user->getRoles() as $userRole) {
             $userRoles[] = $systemRoles[$userRole];
         }
         $status = $user->isActive() ? $this->trans('commands.common.status.enabled') : $this->trans('commands.common.status.disabled');
         $tableRows[] = [$userId, $user->getUsername(), implode(', ', $userRoles), $status];
     }
     $io->table($tableHeader, $tableRows);
 }
Exemplo n.º 16
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $io->section($this->trans('commands.event.debug.messages.event-list'));
     $tableHeader = [$this->trans('commands.event.debug.messages.events')];
     $tableRows = $this->getEvents();
     $io->table($tableHeader, $tableRows, 'compact');
 }
Exemplo n.º 17
0
 /**
  * @param \Drupal\Console\Style\DrupalStyle $io
  * @param $image_handler
  */
 protected function imageStyleList(DrupalStyle $io, $image_handler)
 {
     $tableHeader = [$this->trans('commands.image.styles.debug.messages.styles-name'), $this->trans('commands.image.styles.debug.messages.styles-label')];
     foreach ($image_handler->loadMultiple() as $styles) {
         $tableRows[] = [$styles->get('name'), $styles->get('label')];
     }
     $io->table($tableHeader, $tableRows);
 }
Exemplo n.º 18
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $yaml = new Parser();
     $yaml_left = $input->getArgument('yaml-left');
     $yaml_right = $input->getArgument('yaml-right');
     $stats = $input->getOption('stats');
     $negate = $input->getOption('negate');
     $limit = $input->getOption('limit');
     $offset = $input->getOption('offset');
     if ($negate == 1 || $negate == 'TRUE') {
         $negate = true;
     } else {
         $negate = false;
     }
     try {
         $yamlLeftParsed = $yaml->parse(file_get_contents($yaml_left));
         if (empty($yamlLeftParsed)) {
             $io->error(sprintf($this->trans('commands.yaml.merge.messages.wrong-parse'), $yaml_left));
         }
         $yamlRightParsed = $yaml->parse(file_get_contents($yaml_right));
         if (empty($yamlRightParsed)) {
             $io->error(sprintf($this->trans('commands.yaml.merge.messages.wrong-parse'), $yaml_right));
         }
     } catch (\Exception $e) {
         $io->error($this->trans('commands.yaml.merge.messages.error-parsing') . ': ' . $e->getMessage());
         return;
     }
     $nestedArray = $this->getNestedArrayHelper();
     $statistics = ['total' => 0, 'equal' => 0, 'diff' => 0];
     $diff = $nestedArray->arrayDiff($yamlLeftParsed, $yamlRightParsed, $negate, $statistics);
     if ($stats) {
         $io->info(sprintf($this->trans('commands.yaml.diff.messages.total'), $statistics['total']));
         $io->info(sprintf($this->trans('commands.yaml.diff.messages.diff'), $statistics['diff']));
         $io->info(sprintf($this->trans('commands.yaml.diff.messages.equal'), $statistics['equal']));
         return;
     }
     // FLAT YAML file to display full yaml to be used with command yaml:update:key or yaml:update:value
     $diff_flatten = array();
     $key_flatten = '';
     $nestedArray->yamlFlattenArray($diff, $diff_flatten, $key_flatten);
     if ($limit !== null) {
         if (!$offset) {
             $offset = 0;
         }
         $diff_flatten = array_slice($diff_flatten, $offset, $limit);
     }
     $tableHeader = [$this->trans('commands.yaml.diff.messages.key'), $this->trans('commands.yaml.diff.messages.value')];
     $tableRows = [];
     foreach ($diff_flatten as $yaml_key => $yaml_value) {
         $tableRows[] = [$yaml_key, $yaml_value];
     }
     $io->table($tableHeader, $tableRows, 'compact');
 }
Exemplo n.º 19
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $passwords = $input->getArgument('password');
     $tableHeader = [$this->trans('commands.user.password.hash.messages.password'), $this->trans('commands.user.password.hash.messages.hash')];
     $tableRows = [];
     foreach ($passwords as $password) {
         $tableRows[] = [$password, $password->hash($password)];
     }
     $io->table($tableHeader, $tableRows, 'compact');
 }
Exemplo n.º 20
0
 protected function restList(DrupalStyle $io, $status)
 {
     $rest_resources = $this->getRestResources($status);
     $tableHeader = [$this->trans('commands.rest.debug.messages.id'), $this->trans('commands.rest.debug.messages.label'), $this->trans('commands.rest.debug.messages.canonical_url'), $this->trans('commands.rest.debug.messages.status'), $this->trans('commands.rest.debug.messages.provider')];
     $tableRows = [];
     foreach ($rest_resources as $status => $resources) {
         foreach ($resources as $id => $resource) {
             $tableRows[] = [$id, $resource['label'], $resource['uri_paths']['canonical'], $status, $resource['provider']];
         }
     }
     $io->table($tableHeader, $tableRows, 'compact');
 }
Exemplo n.º 21
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $contextManager = \Drupal::service('cache_contexts_manager');
     $tableHeader = [$this->trans('commands.cache.context.debug.messages.code'), $this->trans('commands.cache.context.debug.messages.label'), $this->trans('commands.cache.context.debug.messages.class')];
     $tableRows = [];
     foreach ($contextManager->getAll() as $code) {
         $context = \Drupal::service('cache_context.' . $code);
         $tableRows[] = [\Drupal\Component\Utility\SafeMarkup::checkPlain($code), $context->getLabel()->render(), get_class($context)];
     }
     $io->table($tableHeader, $tableRows, 'compact');
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $services = $this->getServices();
     $tableHeader = [$this->trans('commands.container.debug.messages.service_id'), $this->trans('commands.container.debug.messages.class_name')];
     $tableRows = [];
     foreach ($services as $serviceId) {
         $service = $this->getContainer()->get($serviceId);
         $class = get_class($service);
         $tableRows[] = [$serviceId, $class];
     }
     $io->table($tableHeader, $tableRows, 'compact');
 }
Exemplo n.º 23
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $nodeId = $input->getArgument('node-id') ?: 1;
     $limit = $input->getOption('limit') ?: 25;
     $titleWords = $input->getOption('title-words') ?: 5;
     $timeRange = $input->getOption('time-range') ?: 31536000;
     $comments = $this->createCommentData->create($nodeId, $limit, $titleWords, $timeRange);
     $tableHeader = [$this->trans('commands.create.comments.messages.node-id'), $this->trans('commands.create.comments.messages.comment-id'), $this->trans('commands.create.comments.messages.title'), $this->trans('commands.create.comments.messages.created')];
     $io->table($tableHeader, $comments['success']);
     $io->success(sprintf($this->trans('commands.create.comments.messages.created-comments'), $limit));
     return 0;
 }
Exemplo n.º 24
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $contextManager = $this->get('cache_contexts_manager');
     $tableHeader = [$this->trans('commands.cache.context.debug.messages.code'), $this->trans('commands.cache.context.debug.messages.label'), $this->trans('commands.cache.context.debug.messages.class')];
     $tableRows = [];
     foreach ($contextManager->getAll() as $code) {
         $context = $this->get('cache_context.' . $code);
         $tableRows[] = [$code, $context->getLabel()->render(), get_class($context)];
     }
     $io->table($tableHeader, $tableRows, 'compact');
     return 0;
 }
Exemplo n.º 25
0
 /**
  * @param $io             DrupalStyle
  * @param $config_name    String
  */
 private function getConfigurationByName(DrupalStyle $io, $config_name)
 {
     if ($this->configStorage->exists($config_name)) {
         $tableHeader = [$config_name];
         $configuration = $this->configStorage->read($config_name);
         $configurationEncoded = Yaml::encode($configuration);
         $tableRows = [];
         $tableRows[] = [$configurationEncoded];
         $io->table($tableHeader, $tableRows, 'compact');
     } else {
         $io->error(sprintf($this->trans('commands.config.debug.errors.not-exists'), $config_name));
     }
 }
Exemplo n.º 26
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $vocabularies = $input->getArgument('vocabularies');
     $limit = $input->getOption('limit') ?: 10;
     $nameWords = $input->getOption('name-words') ?: 5;
     $createTerms = $this->getDrupalApi()->getCreateTerms();
     $terms = $createTerms->createTerm($vocabularies, $limit, $nameWords);
     $tableHeader = [$this->trans('commands.create.terms.messages.term-id'), $this->trans('commands.create.terms.messages.vocabulary'), $this->trans('commands.create.terms.messages.name')];
     $io->table($tableHeader, $terms['success']);
     $io->success(sprintf($this->trans('commands.create.terms.messages.created-terms'), $limit));
     return;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $service = $input->getArgument('service');
     $parameters = $input->getOption('parameters');
     if ($parameters) {
         $parameterList = $this->getParameterList();
         ksort($parameterList);
         $io->write(Yaml::dump(['parameters' => $parameterList], 4, 2));
         return 0;
     }
     $tableHeader = [];
     if ($service) {
         $tableRows = $this->getServiceDetail($service);
         $io->table($tableHeader, $tableRows, 'compact');
         return 0;
     }
     $tableHeader = [$this->trans('commands.container.debug.messages.service_id'), $this->trans('commands.container.debug.messages.class_name')];
     $tableRows = $this->getServiceList();
     $io->table($tableHeader, $tableRows, 'compact');
     return 0;
 }
Exemplo n.º 28
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $roles = $input->getOption('roles');
     $limit = $input->getOption('limit');
     $uids = $this->splitOption($input->getOption('uid'));
     $usernames = $this->splitOption($input->getOption('username'));
     $mails = $this->splitOption($input->getOption('mail'));
     $entityTypeManager = $this->getDrupalService('entity_type.manager');
     $userStorage = $entityTypeManager->getStorage('user');
     $systemRoles = $this->getApplication()->getDrupalApi()->getRoles();
     $entityQuery = $this->getDrupalService('entity.query');
     $query = $entityQuery->get('user');
     $query->condition('uid', 0, '>');
     $query->sort('uid');
     // uid as option
     if (is_array($uids) && $uids) {
         $group = $query->andConditionGroup()->condition('uid', $uids, 'IN');
         $query->condition($group);
     }
     // username as option
     if (is_array($usernames) && $usernames) {
         $group = $query->andConditionGroup()->condition('name', $usernames, 'IN');
         $query->condition($group);
     }
     // mail as option
     if (is_array($mails) && $mails) {
         $group = $query->andConditionGroup()->condition('mail', $mails, 'IN');
         $query->condition($group);
     }
     if ($roles) {
         $query->condition('roles', is_array($roles) ? $roles : [$roles], 'IN');
     }
     if ($limit) {
         $query->range(0, $limit);
     }
     $results = $query->execute();
     $users = $userStorage->loadMultiple($results);
     $tableHeader = [$this->trans('commands.user.debug.messages.user-id'), $this->trans('commands.user.debug.messages.username'), $this->trans('commands.user.debug.messages.roles'), $this->trans('commands.user.debug.messages.status')];
     $tableRows = [];
     foreach ($users as $userId => $user) {
         $userRoles = [];
         foreach ($user->getRoles() as $userRole) {
             $userRoles[] = $systemRoles[$userRole];
         }
         $status = $user->isActive() ? $this->trans('commands.common.status.enabled') : $this->trans('commands.common.status.disabled');
         $tableRows[] = [$userId, $user->getUsername(), implode(', ', $userRoles), $status];
     }
     $io->table($tableHeader, $tableRows);
 }
Exemplo n.º 29
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $key = $input->getArgument('key');
     if ($key) {
         $io->info($key);
         $io->writeln(Yaml::encode($this->state->get($key)));
         return 0;
     }
     $tableHeader = [$this->trans('commands.state.debug.messages.key')];
     $keyStoreStates = array_keys($this->keyValue->get('state')->getAll());
     $io->table($tableHeader, $keyStoreStates);
     return 0;
 }
Exemplo n.º 30
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $createNodes = $this->getDrupalApi()->getCreateNodes();
     $contentTypes = $input->getArgument('content-types');
     $limit = $input->getOption('limit') ?: 10;
     $titleWords = $input->getOption('title-words') ?: 5;
     $timeRange = $input->getOption('time-range') ?: 'N';
     $nodes = $createNodes->createNode($contentTypes, $limit, $titleWords, $timeRange);
     $tableHeader = [$this->trans('commands.create.nodes.messages.node-id'), $this->trans('commands.create.nodes.messages.content-type'), $this->trans('commands.create.nodes.messages.title'), $this->trans('commands.create.nodes.messages.created')];
     $io->table($tableHeader, $nodes['success']);
     $io->success(sprintf($this->trans('commands.create.nodes.messages.created-nodes'), $limit));
     return;
 }