-
-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4020 fix update execute command (#4027)
* [update:execute] Fixed the post update * [debug:update] Create a trait to show tables * [update:execute] Ask first to execute an update
- Loading branch information
1 parent
241d793
commit 404a026
Showing
3 changed files
with
125 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains Drupal\Console\Command\Shared\ThemeRegionTrait. | ||
*/ | ||
|
||
namespace Drupal\Console\Command\Shared; | ||
|
||
trait UpdateTrait | ||
{ | ||
/** | ||
* @param $updates | ||
* @param $messageKey | ||
* @return mixed | ||
*/ | ||
public function showUpdateTable($updates, $messageKey) | ||
{ | ||
if(!$updates) { | ||
return 1; | ||
} | ||
|
||
$this->getIo()->info($messageKey); | ||
$tableHeader = [ | ||
$this->trans('commands.debug.update.messages.module'), | ||
$this->trans('commands.debug.update.messages.update-n'), | ||
$this->trans('commands.debug.update.messages.description') | ||
]; | ||
$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), | ||
]; | ||
} | ||
} | ||
$this->getIo()->table($tableHeader, $tableRows); | ||
} | ||
|
||
/** | ||
* @param $postUpdates | ||
* @param $messageKey | ||
* @return mixed | ||
*/ | ||
public function showPostUpdateTable($postUpdates, $messageKey) | ||
{ | ||
if(!$postUpdates) { | ||
return 1; | ||
} | ||
|
||
$this->getIo()->info($messageKey); | ||
$tableHeader = [ | ||
$this->trans('commands.debug.update.messages.module'), | ||
$this->trans('commands.debug.update.messages.post-update'), | ||
$this->trans('commands.debug.update.messages.description') | ||
]; | ||
|
||
$tableRows = []; | ||
foreach ($postUpdates as $module => $module_updates) { | ||
foreach ($module_updates['pending'] as $postUpdateFunction => $message) { | ||
$tableRows[] = [ | ||
$module, | ||
$postUpdateFunction, | ||
$message, | ||
]; | ||
} | ||
} | ||
$this->getIo()->table($tableHeader, $tableRows); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters