5 * Contains Drupal\Console\Command\Shared\ExtensionTrait.
8 namespace Drupal\Console\Command\Shared;
10 use Drupal\Console\Core\Style\DrupalStyle;
13 * Class ExtensionTrait
15 * @package Drupal\Console\Command
21 * @param DrupalStyle $io
22 * @param bool|true $module
23 * @param bool|true $theme
24 * @param bool|true $profile
30 public function extensionQuestion(DrupalStyle $io, $module=true, $theme=false, $profile=false)
36 $modules = $this->extensionManager->discoverModules()
44 $themes = $this->extensionManager->discoverThemes()
52 $profiles = $this->extensionManager->discoverProfiles()
60 $extensions = array_merge(
66 if (empty($extensions)) {
67 throw new \Exception('No extension available, execute the proper generator command to generate one.');
70 $extension = $io->choiceNoList(
71 $this->trans('commands.common.questions.extension'),
72 array_keys($extensions)
75 return $extensions[$extension];
79 * @param DrupalStyle $io
85 public function extensionTypeQuestion(DrupalStyle $io)
87 $extensionType = $io->choiceNoList(
88 $this->trans('commands.common.questions.extension-type'),
89 array_keys(['module', 'theme', 'profile'])
92 return $extensionType;