5 * Contains \Drupal\Console\Command\Debug\UpdateCommand.
8 namespace Drupal\Console\Command\Debug;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
12 use Drupal\Console\Core\Command\Command;
13 use Drupal\Core\Update\UpdateRegistry;
14 use Drupal\Console\Utils\Site;
16 class UpdateCommand extends Command
26 protected $postUpdateRegistry;
29 * DebugCommand constructor.
32 * @param UpdateRegistry $postUpdateRegistry
34 public function __construct(
36 UpdateRegistry $postUpdateRegistry
39 $this->postUpdateRegistry = $postUpdateRegistry;
40 parent::__construct();
46 protected function configure()
49 ->setName('debug:update')
50 ->setDescription($this->trans('commands.debug.update.description'))
57 protected function execute(InputInterface $input, OutputInterface $output)
59 $this->site->loadLegacyFile('/core/includes/update.inc');
60 $this->site->loadLegacyFile('/core/includes/install.inc');
62 drupal_load_updates();
63 update_fix_compatibility();
65 $requirements = update_check_requirements();
66 $severity = drupal_requirements_severity($requirements);
67 $updates = update_get_update_list();
69 $this->getIo()->newLine();
71 if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING)) {
72 $this->populateRequirements($requirements);
73 } elseif (empty($updates)) {
74 $this->getIo()->info($this->trans('commands.debug.update.messages.no-updates'));
76 $this->populateUpdate($updates);
77 $this->populatePostUpdate();
82 * @param $requirements
84 private function populateRequirements($requirements)
86 $this->getIo()->info($this->trans('commands.debug.update.messages.requirements-error'));
89 $this->trans('commands.debug.update.messages.severity'),
90 $this->trans('commands.debug.update.messages.title'),
91 $this->trans('commands.debug.update.messages.value'),
92 $this->trans('commands.debug.update.messages.description'),
96 foreach ($requirements as $requirement) {
98 $requirement['minimum schema'],
99 [REQUIREMENT_ERROR, REQUIREMENT_WARNING]
101 if ((isset($requirement['minimum schema'])) && ($minimum)) {
103 $requirement['severity'],
104 $requirement['title'],
105 $requirement['value'],
106 $requirement['description'],
111 $this->getIo()->table($tableHeader, $tableRows);
117 private function populateUpdate($updates)
119 $this->getIo()->info($this->trans('commands.debug.update.messages.module-list'));
121 $this->trans('commands.debug.update.messages.module'),
122 $this->trans('commands.debug.update.messages.update-n'),
123 $this->trans('commands.debug.update.messages.description')
126 foreach ($updates as $module => $module_updates) {
127 foreach ($module_updates['pending'] as $update_n => $update) {
128 list(, $description) = explode($update_n . " - ", $update);
136 $this->getIo()->table($tableHeader, $tableRows);
139 private function populatePostUpdate()
141 $this->getIo()->info(
142 $this->trans('commands.debug.update.messages.module-list-post-update')
145 $this->trans('commands.debug.update.messages.module'),
146 $this->trans('commands.debug.update.messages.post-update'),
147 $this->trans('commands.debug.update.messages.description')
150 $postUpdates = $this->postUpdateRegistry->getPendingUpdateInformation();
152 foreach ($postUpdates as $module => $module_updates) {
153 foreach ($module_updates['pending'] as $postUpdateFunction => $message) {
161 $this->getIo()->table($tableHeader, $tableRows);