class DrushCommands in Media entity 8.2
Add commands for Drush 9.
Hierarchy
- class \Drupal\media_entity\Commands\DrushCommands extends \Drush\Commands\DrushCommands
Expanded class hierarchy of DrushCommands
1 string reference to 'DrushCommands'
1 service uses DrushCommands
File
- src/
Commands/ DrushCommands.php, line 11
Namespace
Drupal\media_entity\CommandsView source
class DrushCommands extends DrushCommandsBase {
/**
* The cli service.
*
* @var \Drupal\media_entity\CliService
*/
protected $cliService;
/**
* MediaEntityCommands constructor.
*
* @param \Drupal\media_entity\CliService $cli_service
* The CLI service which allows interoperability.
*/
public function __construct(CliService $cli_service) {
$this->cliService = $cli_service;
}
/**
* Check upgrade requirements for Media Entity into Media in core.
*
* @command media_entity:check-upgrade
* @usage drush mecu
* Checks upgrade requirements for Media Entity while upgrading to Media in
* core.
* @aliases mecu,media-entity-check-upgrade
*/
public function mediaEntityCheckUpgrade() {
$logger = $this
->logger();
// This command is useless if the DB updates have already been run.
if (drupal_get_installed_schema_version('media_entity') >= 8201) {
$logger
->success(dt('Your site has already run the media_entity DB updates. If you believe this is not correct, you should consider rolling back your database to a previous backup and try again.'));
return;
}
$checks = $this->cliService
->validateDbUpdateRequirements();
if (empty($checks['errors'])) {
$logger
->success(sprintf("\33[1;32;40m\33[1m%s\33[0m", '✓') . ' ' . dt('All upgrade requirements are met and you can proceed with the DB updates.'));
}
else {
$logger
->error(sprintf("\33[31;40m\33[1m%s\33[0m", '✗') . ' ' . dt('Your site did not pass all upgrade checks. You can find more information in the error messages below.'));
}
foreach ($checks['passes'] as $pass_msg) {
$logger
->success($pass_msg);
}
foreach ($checks['errors'] as $error_msg) {
$logger
->error($error_msg);
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrushCommands:: |
protected | property | The cli service. | |
DrushCommands:: |
public | function | Check upgrade requirements for Media Entity into Media in core. | |
DrushCommands:: |
public | function | MediaEntityCommands constructor. |