X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FGenerate%2FModuleCommand.php;h=0330fb564137d5eb07df744131dd1ed422ec88d5;hp=1127bcefe375b54d223489256e97dbe4641cfbb7;hb=eba34333e3c89f208d2f72fa91351ad019a71583;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae diff --git a/vendor/drupal/console/src/Command/Generate/ModuleCommand.php b/vendor/drupal/console/src/Command/Generate/ModuleCommand.php index 1127bcefe..0330fb564 100644 --- a/vendor/drupal/console/src/Command/Generate/ModuleCommand.php +++ b/vendor/drupal/console/src/Command/Generate/ModuleCommand.php @@ -19,9 +19,6 @@ use Drupal\Console\Utils\Validator; use Drupal\Console\Core\Command\Shared\CommandTrait; use Drupal\Console\Core\Utils\StringConverter; use Drupal\Console\Utils\DrupalApi; -use GuzzleHttp\Client; -use Drupal\Console\Utils\Site; -use GuzzleHttp\Exception\ClientException; class ModuleCommand extends Command { @@ -29,13 +26,13 @@ class ModuleCommand extends Command use CommandTrait; /** - * @var ModuleGenerator -*/ + * @var ModuleGenerator + */ protected $generator; /** - * @var Validator -*/ + * @var Validator + */ protected $validator; /** @@ -53,16 +50,6 @@ class ModuleCommand extends Command */ protected $drupalApi; - /** - * @var Client - */ - protected $httpClient; - - /** - * @var Site - */ - protected $site; - /** * @var string */ @@ -77,8 +64,6 @@ class ModuleCommand extends Command * @param $appRoot * @param StringConverter $stringConverter * @param DrupalApi $drupalApi - * @param Client $httpClient - * @param Site $site * @param $twigtemplate */ public function __construct( @@ -87,8 +72,6 @@ class ModuleCommand extends Command $appRoot, StringConverter $stringConverter, DrupalApi $drupalApi, - Client $httpClient, - Site $site, $twigtemplate = null ) { $this->generator = $generator; @@ -96,8 +79,6 @@ class ModuleCommand extends Command $this->appRoot = $appRoot; $this->stringConverter = $stringConverter; $this->drupalApi = $drupalApi; - $this->httpClient = $httpClient; - $this->site = $site; $this->twigtemplate = $twigtemplate; parent::__construct(); } @@ -113,73 +94,74 @@ class ModuleCommand extends Command ->setHelp($this->trans('commands.generate.module.help')) ->addOption( 'module', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.module.options.module') ) ->addOption( 'machine-name', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.module.options.machine-name') ) ->addOption( 'module-path', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.module.options.module-path') ) ->addOption( 'description', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.module.options.description') ) ->addOption( 'core', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.module.options.core') ) ->addOption( 'package', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.module.options.package') ) ->addOption( 'module-file', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.generate.module.options.module-file') ) ->addOption( 'features-bundle', - '', + null, InputOption::VALUE_REQUIRED, $this->trans('commands.generate.module.options.features-bundle') ) ->addOption( 'composer', - '', + null, InputOption::VALUE_NONE, $this->trans('commands.generate.module.options.composer') ) ->addOption( 'dependencies', - '', + null, InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.module.options.dependencies') + $this->trans('commands.generate.module.options.dependencies'), + '' ) ->addOption( 'test', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.module.options.test') ) ->addOption( 'twigtemplate', - '', + null, InputOption::VALUE_OPTIONAL, $this->trans('commands.generate.module.options.twigtemplate') ); @@ -195,7 +177,7 @@ class ModuleCommand extends Command // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration if (!$this->confirmGeneration($io, $yes)) { - return; + return 1; } $module = $this->validator->validateModuleName($input->getOption('module')); @@ -210,24 +192,13 @@ class ModuleCommand extends Command $moduleFile = $input->getOption('module-file'); $featuresBundle = $input->getOption('features-bundle'); $composer = $input->getOption('composer'); + $dependencies = $this->validator->validateExtensions( + $input->getOption('dependencies'), + 'module', + $io + ); $test = $input->getOption('test'); - $twigtemplate = $input->getOption('twigtemplate'); - - // Modules Dependencies, re-factor and share with other commands - $dependencies = $this->validator->validateModuleDependencies($input->getOption('dependencies')); - // Check if all module dependencies are available - if ($dependencies) { - $checked_dependencies = $this->checkDependencies($dependencies['success'], $io); - if (!empty($checked_dependencies['no_modules'])) { - $io->warning( - sprintf( - $this->trans('commands.generate.module.warnings.module-unavailable'), - implode(', ', $checked_dependencies['no_modules']) - ) - ); - } - $dependencies = $dependencies['success']; - } + $twigTemplate = $input->getOption('twigtemplate'); $this->generator->generate( $module, @@ -241,49 +212,10 @@ class ModuleCommand extends Command $composer, $dependencies, $test, - $twigtemplate + $twigTemplate ); - } - - /** - * @param array $dependencies - * @return array - */ - private function checkDependencies(array $dependencies, DrupalStyle $io) - { - $this->site->loadLegacyFile('/core/modules/system/system.module'); - $localModules = []; - - $modules = system_rebuild_module_data(); - foreach ($modules as $module_id => $module) { - array_push($localModules, basename($module->subpath)); - } - - $checkDependencies = [ - 'local_modules' => [], - 'drupal_modules' => [], - 'no_modules' => [], - ]; - - foreach ($dependencies as $module) { - if (in_array($module, $localModules)) { - $checkDependencies['local_modules'][] = $module; - } else { - try { - $response = $this->httpClient->head('https://www.drupal.org/project/' . $module); - $header_link = explode(';', $response->getHeader('link')); - if (empty($header_link[0])) { - $checkDependencies['no_modules'][] = $module; - } else { - $checkDependencies['drupal_modules'][] = $module; - } - } catch (ClientException $e) { - $checkDependencies['no_modules'][] = $module; - } - } - } - return $checkDependencies; + return 0; } /** @@ -303,7 +235,7 @@ class ModuleCommand extends Command } catch (\Exception $error) { $io->error($error->getMessage()); - return; + return 1; } if (!$module) {