X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FShared%2FModuleTrait.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FShared%2FModuleTrait.php;h=88b52c1ab42487b69d10c343d32790b5c3df3617;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drupal/console/src/Command/Shared/ModuleTrait.php b/vendor/drupal/console/src/Command/Shared/ModuleTrait.php new file mode 100644 index 000000000..88b52c1ab --- /dev/null +++ b/vendor/drupal/console/src/Command/Shared/ModuleTrait.php @@ -0,0 +1,89 @@ +extensionManager->discoverModules() + ->showInstalled() + ->showUninstalled() + ->showNoCore() + ->getList(true); + + if ($showProfile) { + $profiles = $this->extensionManager->discoverProfiles() + ->showInstalled() + ->showUninstalled() + ->showNoCore() + ->showCore() + ->getList(true); + + $modules = array_merge($modules, $profiles); + } + + if (empty($modules)) { + throw new \Exception('No extension available, execute the proper generator command to generate one.'); + } + + $module = $io->choiceNoList( + $this->trans('commands.common.questions.module'), + $modules + ); + + return $module; + } + + /** + * Verify that install requirements for a list of modules are met. + * + * @param string[] $module + * List of modules to verify. + * @param DrupalStyle $io + * Console interface. + * + * @throws \Exception + * When one or more requirements are not met. + */ + public function moduleRequirement(array $module, DrupalStyle $io) + { + // TODO: Module dependencies should also be checked + // for unmet requirements recursively. + $fail = false; + foreach ($module as $module_name) { + module_load_install($module_name); + if ($requirements = \Drupal::moduleHandler()->invoke($module_name, 'requirements', ['install'])) { + foreach ($requirements as $requirement) { + if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) { + $io->info("Module '{$module_name}' cannot be installed: " . $requirement['title'] . ' | ' . $requirement['value']); + $fail = true; + } + } + } + } + if ($fail) { + throw new \Exception("Some module install requirements are not met."); + } + } +}