Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / media_entity / src / Commands / DrushCommands.php
1 <?php
2
3 namespace Drupal\media_entity\Commands;
4
5 use Drush\Commands\DrushCommands as DrushCommandsBase;
6 use Drupal\media_entity\CliService;
7
8 /**
9  * Add commands for Drush 9.
10  */
11 class DrushCommands extends DrushCommandsBase {
12
13   /**
14    * The cli service.
15    *
16    * @var \Drupal\media_entity\CliService
17    */
18   protected $cliService;
19
20   /**
21    * MediaEntityCommands constructor.
22    *
23    * @param \Drupal\media_entity\CliService $cli_service
24    *   The CLI service which allows interoperability.
25    */
26   public function __construct(CliService $cli_service) {
27     $this->cliService = $cli_service;
28   }
29
30   /**
31    * Check upgrade requirements for Media Entity into Media in core.
32    *
33    * @command media_entity:check-upgrade
34    * @usage drush mecu
35    *   Checks upgrade requirements for Media Entity while upgrading to Media in
36    *   core.
37    * @aliases mecu,media-entity-check-upgrade
38    */
39   public function mediaEntityCheckUpgrade() {
40     drush_bootstrap_to_phase(DRUSH_BOOTSTRAP_DRUPAL_FULL);
41     $logger = $this->logger();
42     // This command is useless if the DB updates have already been run.
43     if (drupal_get_installed_schema_version('media_entity') >= 8201) {
44       $logger(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.'));
45       return;
46     }
47
48     $checks = $this->cliService->validateDbUpdateRequirements();
49
50     if (empty($checks['errors'])) {
51       $logger->success(sprintf("\033[1;32;40m\033[1m%s\033[0m", '✓') . ' ' . dt('All upgrade requirements are met and you can proceed with the DB updates.'));
52     }
53     else {
54       $logger->error(sprintf("\033[31;40m\033[1m%s\033[0m", '✗') . ' ' . dt('Your site did not pass all upgrade checks. You can find more information in the error messages below.'));
55     }
56     foreach ($checks['passes'] as $pass_msg) {
57       $logger->success($pass_msg);
58     }
59     foreach ($checks['errors'] as $error_msg) {
60       $logger->error($error_msg);
61     }
62   }
63
64 }