diff --git a/src/Annotations/DrupalCommand.php b/src/Annotations/DrupalCommand.php index 8be4fd025..5163c53c3 100644 --- a/src/Annotations/DrupalCommand.php +++ b/src/Annotations/DrupalCommand.php @@ -29,5 +29,4 @@ class DrupalCommand * @var array */ public $dependencies; - } diff --git a/src/Annotations/DrupalCommandAnnotationReader.php b/src/Annotations/DrupalCommandAnnotationReader.php index c2e13eb13..b432bdb0b 100644 --- a/src/Annotations/DrupalCommandAnnotationReader.php +++ b/src/Annotations/DrupalCommandAnnotationReader.php @@ -8,8 +8,8 @@ * Class DrupalCommandReader * @package Drupal\Console\Annotations */ -class DrupalCommandAnnotationReader { - +class DrupalCommandAnnotationReader +{ /** * @param $class * @return array @@ -22,7 +22,7 @@ public function readAnnotation($class) new \ReflectionClass($class), 'Drupal\\Console\\Annotations\\DrupalCommand' ); - if($drupalCommandAnnotation) { + if ($drupalCommandAnnotation) { $annotation['extension'] = $drupalCommandAnnotation->extension?:''; $annotation['extensionType'] = $drupalCommandAnnotation->extensionType?:''; $annotation['dependencies'] = $drupalCommandAnnotation->dependencies?:[]; diff --git a/src/Application.php b/src/Application.php index b3d9aa963..7d6eba6f2 100644 --- a/src/Application.php +++ b/src/Application.php @@ -344,7 +344,8 @@ private function commandData($commandName) return $data; } - public function setContainer($container) { + public function setContainer($container) + { $this->container = $container; $this->registerGenerators(); $this->registerCommands(); diff --git a/src/Bootstrap/Drupal.php b/src/Bootstrap/Drupal.php index a43604245..eeb0c2276 100644 --- a/src/Bootstrap/Drupal.php +++ b/src/Bootstrap/Drupal.php @@ -42,18 +42,17 @@ public function boot() $argvInputReader = new ArgvInputReader(); if ($argvInputReader->get('uri')) { - $uri = $argvInputReader->get('uri'); - if (substr($uri, -1) != '/') { - $uri .= '/'; - } - $uri .= 'index.php'; - $request = Request::create($uri, 'GET', array() , array(), array(), array('SCRIPT_NAME' => $this->appRoot . '/index.php')); - } - else { - $request = Request::createFromGlobals(); + $uri = $argvInputReader->get('uri'); + if (substr($uri, -1) != '/') { + $uri .= '/'; + } + $uri .= 'index.php'; + $request = Request::create($uri, 'GET', array(), array(), array(), array('SCRIPT_NAME' => $this->appRoot . '/index.php')); + } else { + $request = Request::createFromGlobals(); } - $drupalKernel = DrupalKernel::createFromRequest ( + $drupalKernel = DrupalKernel::createFromRequest( $request, $this->autoload, 'prod', diff --git a/src/Command/Config/DebugCommand.php b/src/Command/Config/DebugCommand.php index df057cf84..5faf3dcb4 100644 --- a/src/Command/Config/DebugCommand.php +++ b/src/Command/Config/DebugCommand.php @@ -21,10 +21,14 @@ class DebugCommand extends Command { use CommandTrait; - /** @var ConfigFactory */ + /** + * @var ConfigFactory + */ protected $configFactory; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; /** diff --git a/src/Command/Config/DeleteCommand.php b/src/Command/Config/DeleteCommand.php index bc4c5b602..5aa6f3676 100644 --- a/src/Command/Config/DeleteCommand.php +++ b/src/Command/Config/DeleteCommand.php @@ -23,13 +23,19 @@ class DeleteCommand extends Command protected $allConfig = []; - /** @var ConfigFactory */ + /** + * @var ConfigFactory + */ protected $configFactory; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var FileStorage */ + /** + * @var FileStorage + */ protected $configStorageSync; /** @@ -39,7 +45,7 @@ class DeleteCommand extends Command * @param FileStorage $configStorageSync */ public function __construct( - ConfigFactory $configFactory , + ConfigFactory $configFactory, CachedStorage $configStorage, FileStorage $configStorageSync ) { diff --git a/src/Command/Config/DiffCommand.php b/src/Command/Config/DiffCommand.php index 117154b1b..86417ab71 100644 --- a/src/Command/Config/DiffCommand.php +++ b/src/Command/Config/DiffCommand.php @@ -22,10 +22,14 @@ class DiffCommand extends Command { use CommandTrait; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var ConfigManager */ + /** + * @var ConfigManager + */ protected $configManager; /** diff --git a/src/Command/Config/EditCommand.php b/src/Command/Config/EditCommand.php index 1ccb592e7..cfad573d7 100644 --- a/src/Command/Config/EditCommand.php +++ b/src/Command/Config/EditCommand.php @@ -26,23 +26,29 @@ class EditCommand extends Command { use CommandTrait; - /** @var ConfigFactory */ + /** + * @var ConfigFactory + */ protected $configFactory; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var ConfigurationManager */ + /** + * @var ConfigurationManager + */ protected $configurationManager; /** * EditCommand constructor. - * @param ConfigFactory $configFactory - * @param CachedStorage $configStorage - * @param ConfigurationManager $configurationManager + * @param ConfigFactory $configFactory + * @param CachedStorage $configStorage + * @param ConfigurationManager $configurationManager */ public function __construct( - ConfigFactory $configFactory , + ConfigFactory $configFactory, CachedStorage $configStorage, ConfigurationManager $configurationManager ) { diff --git a/src/Command/Config/ExportCommand.php b/src/Command/Config/ExportCommand.php index e7dea0366..9f7b9aec3 100644 --- a/src/Command/Config/ExportCommand.php +++ b/src/Command/Config/ExportCommand.php @@ -18,19 +18,21 @@ use Drupal\Console\Style\DrupalStyle; use Drupal\Core\Config\ConfigManager; - class ExportCommand extends Command { use CommandTrait; - /** @var ConfigManager */ + /** + * @var ConfigManager + */ protected $configManager; /** * ExportCommand constructor. * @param ConfigManager $configManager */ - public function __construct(ConfigManager $configManager ) { + public function __construct(ConfigManager $configManager) + { $this->configManager = $configManager; parent::__construct(); } @@ -142,9 +144,9 @@ protected function execute(InputInterface $input, OutputInterface $output) } $io->info( - sprintf( - $this->trans('commands.config.export.messages.directory'), - $directory + sprintf( + $this->trans('commands.config.export.messages.directory'), + $directory ) ); } diff --git a/src/Command/Config/ExportContentTypeCommand.php b/src/Command/Config/ExportContentTypeCommand.php index b8d938e9d..cb94f7cfc 100644 --- a/src/Command/Config/ExportContentTypeCommand.php +++ b/src/Command/Config/ExportContentTypeCommand.php @@ -26,13 +26,19 @@ class ExportContentTypeCommand extends Command use ModuleTrait; use ExportTrait; - /** @var EntityTypeManager */ + /** + * @var EntityTypeManagerInterface + */ protected $entityTypeManager; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; protected $configExport; @@ -40,8 +46,8 @@ class ExportContentTypeCommand extends Command /** * ExportContentTypeCommand constructor. * @param EntityTypeManagerInterface $entityTypeManager - * @param CachedStorage $configStorage - * @param Manager $extensionManager + * @param CachedStorage $configStorage + * @param Manager $extensionManager */ public function __construct( EntityTypeManagerInterface $entityTypeManager, @@ -199,4 +205,4 @@ protected function getViewDisplays($contentType, $optional = false) } } } -} \ No newline at end of file +} diff --git a/src/Command/Config/ExportSingleCommand.php b/src/Command/Config/ExportSingleCommand.php index fe877a420..4a63b1d7f 100644 --- a/src/Command/Config/ExportSingleCommand.php +++ b/src/Command/Config/ExportSingleCommand.php @@ -29,10 +29,14 @@ class ExportSingleCommand extends Command */ protected $definitions; - /** @var EntityTypeManagerInterface */ + /** + * @var EntityTypeManagerInterface + */ protected $entityTypeManager; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; protected $configExport; @@ -40,7 +44,7 @@ class ExportSingleCommand extends Command /** * ExportSingleCommand constructor. * @param EntityTypeManagerInterface $entityTypeManager - * @param CachedStorage $configStorage + * @param CachedStorage $configStorage */ public function __construct( EntityTypeManagerInterface $entityTypeManager, @@ -57,50 +61,50 @@ public function __construct( protected function configure() { $this - ->setName('config:export:single') - ->setDescription($this->trans('commands.config.export.single.description')) - ->addArgument( - 'config-name', - InputArgument::OPTIONAL, - $this->trans('commands.config.export.single.arguments.config-name') - ) - ->addOption( - 'config-names', - null, - InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, - $this->trans('commands.config.export.single.arguments.config-names') - ) - ->addOption( - 'directory', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.config.export.arguments.directory') - ) - ->addOption( - 'include-dependencies', - '', - InputOption::VALUE_NONE, - $this->trans('commands.config.export.single.options.include-dependencies') - )->addOption( - 'module', '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.common.options.module') - )->addOption( - 'optional-config', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.config.export.single.options.optional-config') - )->addOption( - 'remove-uuid', - '', - InputOption::VALUE_NONE, - $this->trans('commands.config.export.single.options.remove-uuid') - )->addOption( - 'remove-config-hash', - '', - InputOption::VALUE_NONE, - $this->trans('commands.config.export.single.options.remove-config-hash') - ); + ->setName('config:export:single') + ->setDescription($this->trans('commands.config.export.single.description')) + ->addArgument( + 'config-name', + InputArgument::OPTIONAL, + $this->trans('commands.config.export.single.arguments.config-name') + ) + ->addOption( + 'config-names', + null, + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + $this->trans('commands.config.export.single.arguments.config-names') + ) + ->addOption( + 'directory', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.config.export.arguments.directory') + ) + ->addOption( + 'include-dependencies', + '', + InputOption::VALUE_NONE, + $this->trans('commands.config.export.single.options.include-dependencies') + )->addOption( + 'module', '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.common.options.module') + )->addOption( + 'optional-config', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.config.export.single.options.optional-config') + )->addOption( + 'remove-uuid', + '', + InputOption::VALUE_NONE, + $this->trans('commands.config.export.single.options.remove-uuid') + )->addOption( + 'remove-config-hash', + '', + InputOption::VALUE_NONE, + $this->trans('commands.config.export.single.options.remove-config-hash') + ); } /* @@ -114,9 +118,9 @@ protected function getConfigTypes() } } $entity_types = array_map( - function ($definition) { - return $definition->getLabel(); - }, $this->definitions + function ($definition) { + return $definition->getLabel(); + }, $this->definitions ); uasort($entity_types, 'strnatcasecmp'); @@ -146,9 +150,9 @@ protected function getConfigNames($config_type) else { // Gather the config entity prefixes. $config_prefixes = array_map( - function ($definition) { - return $definition->getConfigPrefix() . '.'; - }, $this->definitions + function ($definition) { + return $definition->getConfigPrefix() . '.'; + }, $this->definitions ); // Find all config, and then filter our anything matching a config prefix. @@ -178,15 +182,15 @@ protected function interact(InputInterface $input, OutputInterface $output) $config_name = $input->getArgument('config-name'); if (!$config_name) { $config_type = $io->choiceNoList( - $this->trans('commands.config.export.single.questions.config-type'), - array_keys($config_types), - $this->trans('commands.config.export.single.options.simple-configuration') + $this->trans('commands.config.export.single.questions.config-type'), + array_keys($config_types), + $this->trans('commands.config.export.single.options.simple-configuration') ); $config_names = $this->getConfigNames($config_type); $config_name = $io->choiceNoList( - $this->trans('commands.config.export.single.questions.config-name'), - array_keys($config_names) + $this->trans('commands.config.export.single.questions.config-name'), + array_keys($config_names) ); if ($config_type !== 'system.simple') { @@ -203,23 +207,23 @@ protected function interact(InputInterface $input, OutputInterface $output) $optionalConfig = $input->getOption('optional-config'); if (!$optionalConfig) { $optionalConfig = $io->confirm( - $this->trans('commands.config.export.single.questions.optional-config'), - true + $this->trans('commands.config.export.single.questions.optional-config'), + true ); $input->setOption('optional-config', $optionalConfig); } } if (!$input->getOption('remove-uuid')) { $removeUuid = $io->confirm( - $this->trans('commands.config.export.single.questions.remove-uuid'), - true + $this->trans('commands.config.export.single.questions.remove-uuid'), + true ); $input->setOption('remove-uuid', $removeUuid); } if (!$input->getOption('remove-config-hash')) { $removeHash = $io->confirm( - $this->trans('commands.config.export.single.questions.remove-config-hash'), - true + $this->trans('commands.config.export.single.questions.remove-config-hash'), + true ); $input->setOption('remove-config-hash', $removeHash); } @@ -249,7 +253,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $config = $this->getConfiguration($configName, $removeUuid, $removeHash); $config = $this->getConfiguration($configName, false); - if ($config) { + if ($config) { $this->configExport[$configName] = array('data' => $config, 'optional' => $optionalConfig); if ($input->getOption('include-dependencies')) { diff --git a/src/Command/Config/ExportViewCommand.php b/src/Command/Config/ExportViewCommand.php index 1f15a87ca..c524f1c3e 100644 --- a/src/Command/Config/ExportViewCommand.php +++ b/src/Command/Config/ExportViewCommand.php @@ -29,20 +29,26 @@ class ExportViewCommand extends Command protected $configExport; - /** @var EntityTypeManagerInterface */ + /** + * @var EntityTypeManagerInterface + */ protected $entityTypeManager; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var Manager */ + /** + * @var Manager + */ protected $extensionManager; /** * ExportViewCommand constructor. * @param EntityTypeManagerInterface $entityTypeManager - * @param CachedStorage $configStorage - * @param Manager $extensionManager + * @param CachedStorage $configStorage + * @param Manager $extensionManager */ public function __construct( EntityTypeManagerInterface $entityTypeManager, @@ -103,7 +109,6 @@ protected function interact(InputInterface $input, OutputInterface $output) // view-id argument $viewId = $input->getArgument('view-id'); if (!$viewId) { - $views = $this->entityTypeManager->getStorage('view')->loadMultiple(); $viewList = []; diff --git a/src/Command/Config/ImportCommand.php b/src/Command/Config/ImportCommand.php index 5ee0a2d57..403e3cb24 100644 --- a/src/Command/Config/ImportCommand.php +++ b/src/Command/Config/ImportCommand.php @@ -26,10 +26,14 @@ class ImportCommand extends Command { use CommandTrait; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var ConfigManager */ + /** + * @var ConfigManager + */ protected $configManager; /** diff --git a/src/Command/Config/ImportSingleCommand.php b/src/Command/Config/ImportSingleCommand.php index 3d4e0cc2b..3b0f7e8b4 100644 --- a/src/Command/Config/ImportSingleCommand.php +++ b/src/Command/Config/ImportSingleCommand.php @@ -25,10 +25,14 @@ class ImportSingleCommand extends Command { use CommandTrait; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var ConfigManager */ + /** + * @var ConfigManager + */ protected $configManager; /** @@ -54,12 +58,12 @@ protected function configure() ->setName('config:import:single') ->setDescription($this->trans('commands.config.import.single.description')) ->addArgument( - 'name', InputArgument::OPTIONAL, - $this->trans('commands.config.import.single.arguments.name') + 'name', InputArgument::OPTIONAL, + $this->trans('commands.config.import.single.arguments.name') ) ->addArgument( - 'file', InputArgument::OPTIONAL, - $this->trans('commands.config.import.single.arguments.file') + 'file', InputArgument::OPTIONAL, + $this->trans('commands.config.import.single.arguments.file') ) ->addOption( 'config-names', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, @@ -86,9 +90,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $configNameArg = $input->getArgument('name'); $fileName = $input->getArgument('file'); - $singleMode = FALSE; + $singleMode = false; if (empty($configNames) && isset($configNameArg)) { - $singleMode = TRUE; + $singleMode = true; $configNames = array($configNameArg); } @@ -99,7 +103,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $ymlFile = new Parser(); try { $source_storage = new StorageReplaceDataWrapper( - $this->configStorage + $this->configStorage ); foreach ($configNames as $configName) { @@ -108,7 +112,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $configName = substr($configName, 0, -4); } - if ($singleMode === FALSE) { + if ($singleMode === false) { $fileName = $directory.DIRECTORY_SEPARATOR.$configName.'.yml'; } @@ -127,19 +131,19 @@ protected function execute(InputInterface $input, OutputInterface $output) } $storage_comparer = new StorageComparer( - $source_storage, - $this->configStorage, - $this->configManager + $source_storage, + $this->configStorage, + $this->configManager ); if ($this->configImport($io, $storage_comparer)) { $io->success( - sprintf( - $this->trans( - 'commands.config.import.single.messages.success' - ), - implode(", ", $configNames) - ) + sprintf( + $this->trans( + 'commands.config.import.single.messages.success' + ), + implode(", ", $configNames) + ) ); } } catch (\Exception $e) { @@ -177,7 +181,7 @@ private function configImport($io, StorageComparer $storage_comparer) } while ($context['finished'] < 1); } - return TRUE; + return true; } } catch (ConfigImporterException $e) { $message = 'The import failed due for the following reasons:' . "\n"; diff --git a/src/Command/Config/OverrideCommand.php b/src/Command/Config/OverrideCommand.php index dd6c40c24..3d0991841 100644 --- a/src/Command/Config/OverrideCommand.php +++ b/src/Command/Config/OverrideCommand.php @@ -20,10 +20,14 @@ class OverrideCommand extends Command { use CommandTrait; - /** @var CachedStorage */ + /** + * @var CachedStorage + */ protected $configStorage; - /** @var ConfigFactory */ + /** + * @var ConfigFactory + */ protected $configFactory; /** diff --git a/src/Command/Config/PrintConfigValidationTrait.php b/src/Command/Config/PrintConfigValidationTrait.php index a0fcf2009..6dcbe6624 100644 --- a/src/Command/Config/PrintConfigValidationTrait.php +++ b/src/Command/Config/PrintConfigValidationTrait.php @@ -9,20 +9,18 @@ use Drupal\Console\Style\DrupalStyle; - -trait PrintConfigValidationTrait { - - protected function printResults($valid, DrupalStyle $io){ - - if($valid === TRUE){ - $io->info($this->trans('commands.config.validate.messages.success')); - return 0; +trait PrintConfigValidationTrait +{ + protected function printResults($valid, DrupalStyle $io) + { + if ($valid === true) { + $io->info($this->trans('commands.config.validate.messages.success')); + return 0; + } + + foreach ($valid as $key => $error) { + $io->warning($key . ': ' . $error); + } + return 1; } - - foreach ($valid as $key => $error) { - $io->warning($key . ': ' . $error); - } - return 1; - } - -} \ No newline at end of file +} diff --git a/src/Command/Config/SettingsDebugCommand.php b/src/Command/Config/SettingsDebugCommand.php index 33de258ef..80bad753e 100644 --- a/src/Command/Config/SettingsDebugCommand.php +++ b/src/Command/Config/SettingsDebugCommand.php @@ -23,15 +23,19 @@ class SettingsDebugCommand extends Command { use CommandTrait; - /** @var Settings */ + /** + * @var Settings + */ protected $settings; /** * SettingsDebugCommand constructor. * @param Settings $settings */ - public function __construct(Settings $settings) { - $this->settings = $settings;; + public function __construct(Settings $settings) + { + $this->settings = $settings; + ; parent::__construct(); } /** diff --git a/src/Command/Config/ValidateCommand.php b/src/Command/Config/ValidateCommand.php index e8427a5bd..5bf4b2e4c 100644 --- a/src/Command/Config/ValidateCommand.php +++ b/src/Command/Config/ValidateCommand.php @@ -13,7 +13,6 @@ use Drupal\Console\Command\Shared\ContainerAwareCommandTrait; use Drupal\Console\Style\DrupalStyle; use Drupal\Core\Config\TypedConfigManagerInterface; -use Drupal\Core\Config\ConfigFactoryInterface; use Symfony\Component\Console\Input\InputArgument; use Drupal\Core\Config\Schema\SchemaCheckTrait; @@ -22,53 +21,53 @@ * * @package Drupal\Console\Command\Config */ -class ValidateCommand extends Command { - - use ContainerAwareCommandTrait; - use SchemaCheckTrait; - use PrintConfigValidationTrait; - - public function __construct($name) { - - parent::__construct($name); - - } +class ValidateCommand extends Command +{ + use ContainerAwareCommandTrait; + use SchemaCheckTrait; + use PrintConfigValidationTrait; + + public function __construct($name) + { + parent::__construct($name); + } - /** + /** * {@inheritdoc} */ - protected function configure() { - - $this - ->setName('config:validate') - ->setDescription($this->trans('commands.config.default.description')) - ->addArgument('config.name',InputArgument::REQUIRED); - - } + protected function configure() + { + $this + ->setName('config:validate') + ->setDescription($this->trans('commands.config.default.description')) + ->addArgument('config.name', InputArgument::REQUIRED); + } - /** + /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) { + protected function execute(InputInterface $input, OutputInterface $output) + { - /** @var TypedConfigManagerInterface $typedConfigManager */ - $typedConfigManager = $this->get('config.typed'); + /** + * @var TypedConfigManagerInterface $typedConfigManager +*/ + $typedConfigManager = $this->get('config.typed'); - $io = new DrupalStyle($input, $output); + $io = new DrupalStyle($input, $output); - //Test the config name and see if a schema exists, if not it will fail - $name = $input->getArgument('config.name'); - if(!$typedConfigManager->hasConfigSchema($name)){ - $io->warning($this->trans('commands.config.default.messages.noconf')); - return 1; - } + //Test the config name and see if a schema exists, if not it will fail + $name = $input->getArgument('config.name'); + if (!$typedConfigManager->hasConfigSchema($name)) { + $io->warning($this->trans('commands.config.default.messages.noconf')); + return 1; + } - //Get the config data from the factory - $configFactory = $this->get('config.factory'); - $config_data = $configFactory->get($name)->get(); + //Get the config data from the factory + $configFactory = $this->get('config.factory'); + $config_data = $configFactory->get($name)->get(); - return $this->printResults($this->checkConfigSchema($typedConfigManager, $name, $config_data), $io); - - } + return $this->printResults($this->checkConfigSchema($typedConfigManager, $name, $config_data), $io); + } } diff --git a/src/Command/Config/ValidateDebugCommand.php b/src/Command/Config/ValidateDebugCommand.php index efcf95be0..1768be324 100644 --- a/src/Command/Config/ValidateDebugCommand.php +++ b/src/Command/Config/ValidateDebugCommand.php @@ -23,83 +23,87 @@ * *@package Drupal\Console\Command\Config */ -class ValidateDebugCommand extends Command { - - use ContainerAwareCommandTrait; - use SchemaCheckTrait; - use PrintConfigValidationTrait; +class ValidateDebugCommand extends Command +{ + use ContainerAwareCommandTrait; + use SchemaCheckTrait; + use PrintConfigValidationTrait; + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('config:validate:debug') + ->setDescription($this->trans('commands.config.validate.debug.description')) + ->addArgument('config.filepath', InputArgument::REQUIRED) + ->addArgument('config.schema.filepath', InputArgument::REQUIRED) + ->addOption('schema-name', 'sch', InputOption::VALUE_REQUIRED); + } - /** - * {@inheritdoc} - */ - protected function configure() { - $this - ->setName('config:validate:debug') - ->setDescription($this->trans('commands.config.validate.debug.description')) - ->addArgument('config.filepath', InputArgument::REQUIRED) - ->addArgument('config.schema.filepath', InputArgument::REQUIRED) - ->addOption('schema-name', 'sch', InputOption::VALUE_REQUIRED); - } - - /** + /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) { - - /** @var TypedConfigManagerInterface $typedConfigManager */ - $typedConfigManager = $this->get('config.typed'); - - $io = new DrupalStyle($input, $output); - - //Validate config file path - $configFilePath = $input->getArgument('config.filepath'); - if (!file_exists($configFilePath)) { - $io->info($this->trans('commands.config.validate.debug.messages.noConfFile')); - return 1; - } - - //Validate schema path - $configSchemaFilePath = $input->getArgument('config.schema.filepath'); - if (!file_exists($configSchemaFilePath)) { - $io->info($this->trans('commands.config.validate.debug.messages.noConfSchema')); - return 1; - } - - $config = Yaml::decode(file_get_contents($configFilePath)); - $schema = Yaml::decode(file_get_contents($configSchemaFilePath)); - - //Get the schema name and check it exists in the schema array - $schemaName = $this->getSchemaName($input,$configFilePath); - if(!array_key_exists($schemaName,$schema)){ - $io->warning($this->trans('commands.config.validate.debug.messages.noSchemaName') . $schemaName ); - return 1; + protected function execute(InputInterface $input, OutputInterface $output) + { + + /** + * @var TypedConfigManagerInterface $typedConfigManager + */ + $typedConfigManager = $this->get('config.typed'); + + $io = new DrupalStyle($input, $output); + + //Validate config file path + $configFilePath = $input->getArgument('config.filepath'); + if (!file_exists($configFilePath)) { + $io->info($this->trans('commands.config.validate.debug.messages.noConfFile')); + return 1; + } + + //Validate schema path + $configSchemaFilePath = $input->getArgument('config.schema.filepath'); + if (!file_exists($configSchemaFilePath)) { + $io->info($this->trans('commands.config.validate.debug.messages.noConfSchema')); + return 1; + } + + $config = Yaml::decode(file_get_contents($configFilePath)); + $schema = Yaml::decode(file_get_contents($configSchemaFilePath)); + + //Get the schema name and check it exists in the schema array + $schemaName = $this->getSchemaName($input, $configFilePath); + if (!array_key_exists($schemaName, $schema)) { + $io->warning($this->trans('commands.config.validate.debug.messages.noSchemaName') . $schemaName); + return 1; + } + + return $this->printResults($this->manualCheckConfigSchema($typedConfigManager, $config, $schema[$schemaName]), $io); } - return $this->printResults($this->manualCheckConfigSchema($typedConfigManager,$config,$schema[$schemaName]), $io); - - } - - private function getSchemaName(InputInterface $input, $configFilePath) - { - $schemaName = $input->getOption('schema-name'); - if( $schemaName === null){ - $schema_name = end(explode('/',$configFilePath)); - $schemaName = substr($schema_name, 0, -4); + private function getSchemaName(InputInterface $input, $configFilePath) + { + $schemaName = $input->getOption('schema-name'); + if ($schemaName === null) { + $schema_name = end(explode('/', $configFilePath)); + $schemaName = substr($schema_name, 0, -4); + } + return $schemaName; } - return $schemaName; - } - private function manualCheckConfigSchema(TypedConfigManagerInterface $typed_config, $config_data, $config_schema) { - - $data_definition = $typed_config->buildDataDefinition($config_schema, $config_data); - $this->schema = $typed_config->create($data_definition, $config_data); - $errors = array(); - foreach ($config_data as $key => $value) { - $errors = array_merge($errors, $this->checkValue($key, $value)); - } - if (empty($errors)) { - return TRUE; + private function manualCheckConfigSchema(TypedConfigManagerInterface $typed_config, $config_data, $config_schema) + { + $data_definition = $typed_config->buildDataDefinition($config_schema, $config_data); + $this->schema = $typed_config->create($data_definition, $config_data); + $errors = array(); + foreach ($config_data as $key => $value) { + $errors = array_merge($errors, $this->checkValue($key, $value)); + } + if (empty($errors)) { + return true; + } + + return $errors; } - return $errors; - } } diff --git a/src/Command/Cron/ExecuteCommand.php b/src/Command/Cron/ExecuteCommand.php index d676d4904..f0cd6849b 100644 --- a/src/Command/Cron/ExecuteCommand.php +++ b/src/Command/Cron/ExecuteCommand.php @@ -46,7 +46,7 @@ class ExecuteCommand extends Command * DebugCommand constructor. * @param ModuleHandlerInterface $moduleHandler * @param LockBackendInterface $lock - * @param StateInterface $state + * @param StateInterface $state * @param ChainQueue $chainQueue */ public function __construct( diff --git a/src/Command/Database/ClientCommand.php b/src/Command/Database/ClientCommand.php index 0f9b13b9d..d6a4a494f 100644 --- a/src/Command/Database/ClientCommand.php +++ b/src/Command/Database/ClientCommand.php @@ -50,15 +50,15 @@ protected function execute(InputInterface $input, OutputInterface $output) $databaseConnection = $this->resolveConnection($io, $database); - $connection = sprintf( - '%s -A --database=%s --user=%s --password=%s --host=%s --port=%s', - $databaseConnection['driver'], - $databaseConnection['database'], - $databaseConnection['username'], - $databaseConnection['password'], - $databaseConnection['host'], - $databaseConnection['port'] - ); + $connection = sprintf( + '%s -A --database=%s --user=%s --password=%s --host=%s --port=%s', + $databaseConnection['driver'], + $databaseConnection['database'], + $databaseConnection['username'], + $databaseConnection['password'], + $databaseConnection['host'], + $databaseConnection['port'] + ); if ($learning) { $io->commentBlock( diff --git a/src/Command/Database/DatabaseLogBase.php b/src/Command/Database/DatabaseLogBase.php index 87bacc5b6..fea09034f 100644 --- a/src/Command/Database/DatabaseLogBase.php +++ b/src/Command/Database/DatabaseLogBase.php @@ -24,62 +24,61 @@ use Symfony\Component\Console\Input\InputInterface; use Drupal\Console\Style\DrupalStyle; - /** * Class DatabaseLogBase * * @package Drupal\Console\Command\Database */ -abstract class DatabaseLogBase extends Command { - - use CommandTrait; +abstract class DatabaseLogBase extends Command +{ + use CommandTrait; - /** + /** * @var Connection */ - protected $database; + protected $database; - /** + /** * @var DateFormatterInterface */ - protected $dateFormatter; + protected $dateFormatter; - /** + /** * @var EntityTypeManagerInterface */ - protected $entityTypeManager; + protected $entityTypeManager; - /** + /** * @var TranslationInterface */ - protected $stringTranslation; + protected $stringTranslation; - /** + /** * @var UserStorageInterface */ - protected $userStorage; + protected $userStorage; - /** + /** * @var TranslatableMarkup[] */ - protected $severityList; + protected $severityList; - /** + /** * @var null|string */ - protected $eventType; + protected $eventType; - /** + /** * @var null|string */ - protected $eventSeverity; + protected $eventSeverity; - /** + /** * @var null|string */ - protected $userId; + protected $userId; - /** + /** * LogDebugCommand constructor. * * @param Connection $database @@ -87,154 +86,161 @@ abstract class DatabaseLogBase extends Command { * @param EntityTypeManagerInterface $entityTypeManager * @param \Drupal\Core\StringTranslation\TranslationInterface $stringTranslation */ - public function __construct( - Connection $database, - DateFormatterInterface $dateFormatter, - EntityTypeManagerInterface $entityTypeManager, - TranslationInterface $stringTranslation - ) { - $this->database = $database; - $this->dateFormatter = $dateFormatter; - $this->entityTypeManager = $entityTypeManager; - $this->stringTranslation = $stringTranslation; - $this->userStorage = $this->entityTypeManager->getStorage('user'); - $this->severityList = RfcLogLevel::getLevels(); - parent::__construct(); - } - - /** + public function __construct( + Connection $database, + DateFormatterInterface $dateFormatter, + EntityTypeManagerInterface $entityTypeManager, + TranslationInterface $stringTranslation + ) { + $this->database = $database; + $this->dateFormatter = $dateFormatter; + $this->entityTypeManager = $entityTypeManager; + $this->stringTranslation = $stringTranslation; + $this->userStorage = $this->entityTypeManager->getStorage('user'); + $this->severityList = RfcLogLevel::getLevels(); + parent::__construct(); + } + + /** * */ - protected function addDefaultLoggingOptions() { - - $this - ->addOption( - 'type', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.log.common.options.type') - ) - ->addOption( - 'severity', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.log.common.options.severity') - ) - ->addOption( - 'user-id', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.log.common.options.user-id') - ); - - } - - /** + protected function addDefaultLoggingOptions() + { + $this + ->addOption( + 'type', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.log.common.options.type') + ) + ->addOption( + 'severity', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.log.common.options.severity') + ) + ->addOption( + 'user-id', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.log.common.options.user-id') + ); + } + + /** * @param \Symfony\Component\Console\Input\InputInterface $input */ - protected function getDefaultOptions(InputInterface $input) { - - $this->eventType = $input->getOption('type'); - $this->eventSeverity = $input->getOption('severity'); - $this->userId = $input->getOption('user-id'); - - } + protected function getDefaultOptions(InputInterface $input) + { + $this->eventType = $input->getOption('type'); + $this->eventSeverity = $input->getOption('severity'); + $this->userId = $input->getOption('user-id'); + } - /** + /** * @param \Drupal\Console\Style\DrupalStyle $io * @param null $offset * @param int $range * @return bool|\Drupal\Core\Database\Query\SelectInterface */ - protected function makeQuery(DrupalStyle $io, $offset = NULL, $range = 1000) { - - $query = $this->database->select('watchdog', 'w'); - $query->fields( - 'w', - [ - 'wid', - 'uid', - 'severity', - 'type', - 'timestamp', - 'message', - 'variables', - ] - ); - - if ($this->eventType) { - $query->condition('type', $this->eventType); - } - - if ($this->eventSeverity) { - if (!in_array($this->eventSeverity, $this->severityList)) { - $io->error( - sprintf( - $this->trans('database.log.common.messages.invalid-severity'), - $this->eventSeverity - ) + protected function makeQuery(DrupalStyle $io, $offset = null, $range = 1000) + { + $query = $this->database->select('watchdog', 'w'); + $query->fields( + 'w', + [ + 'wid', + 'uid', + 'severity', + 'type', + 'timestamp', + 'message', + 'variables', + ] ); - return FALSE; - } - $query->condition('severity', - array_search($this->eventSeverity, - $this->severityList)); - } - - if ($this->userId) { - $query->condition('uid', $this->userId); - } - - $query->orderBy('wid', 'ASC'); - if ($offset) { - $query->range($offset, $range); + if ($this->eventType) { + $query->condition('type', $this->eventType); + } + + if ($this->eventSeverity) { + if (!in_array($this->eventSeverity, $this->severityList)) { + $io->error( + sprintf( + $this->trans('database.log.common.messages.invalid-severity'), + $this->eventSeverity + ) + ); + return false; + } + $query->condition( + 'severity', + array_search( + $this->eventSeverity, + $this->severityList + ) + ); + } + + if ($this->userId) { + $query->condition('uid', $this->userId); + } + + $query->orderBy('wid', 'ASC'); + + if ($offset) { + $query->range($offset, $range); + } + + return $query; } - return $query; - - } - - /** + /** * Generic logging table header * * @return array */ - protected function createTableHeader() { - return [ - $this->trans('commands.database.log.common.messages.event-id'), - $this->trans('commands.database.log.common.messages.type'), - $this->trans('commands.database.log.common.messages.date'), - $this->trans('commands.database.log.common.messages.message'), - $this->trans('commands.database.log.common.messages.user'), - $this->trans('commands.database.log.common.messages.severity'), - ]; - } - - - /** + protected function createTableHeader() + { + return [ + $this->trans('commands.database.log.common.messages.event-id'), + $this->trans('commands.database.log.common.messages.type'), + $this->trans('commands.database.log.common.messages.date'), + $this->trans('commands.database.log.common.messages.message'), + $this->trans('commands.database.log.common.messages.user'), + $this->trans('commands.database.log.common.messages.severity'), + ]; + } + + + /** * @param \stdClass $dblog * @return array */ - protected function createTableRow(\stdClass $dblog) { - - /** @var User $user */ - $user = $this->userStorage->load($dblog->uid); - - return [ - $dblog->wid, - $dblog->type, - $this->dateFormatter->format($dblog->timestamp, 'short'), - Unicode::truncate(Html::decodeEntities(strip_tags($this->formatMessage($dblog))), - 500, - TRUE, - TRUE), - $user->getUsername() . ' (' . $user->id() . ')', - $this->severityList[$dblog->severity]->render(), - ]; - } - - /** + protected function createTableRow(\stdClass $dblog) + { + + /** + * @var User $user +*/ + $user = $this->userStorage->load($dblog->uid); + + return [ + $dblog->wid, + $dblog->type, + $this->dateFormatter->format($dblog->timestamp, 'short'), + Unicode::truncate( + Html::decodeEntities(strip_tags($this->formatMessage($dblog))), + 500, + true, + true + ), + $user->getUsername() . ' (' . $user->id() . ')', + $this->severityList[$dblog->severity]->render(), + ]; + } + + /** * Formats a database log message. * * @param $event @@ -245,32 +251,35 @@ protected function createTableRow(\stdClass $dblog) { * The formatted log message or FALSE if the message or variables properties * are not set. */ - protected function formatMessage(\stdClass $event) { - $message = FALSE; - - // Check for required properties. - if (isset($event->message, $event->variables)) { - // Messages without variables or user specified text. - if ($event->variables === 'N;') { - return $event->message; - } - - return $this->stringTranslation->translate( - $event->message, - unserialize($event->variables) - ); + protected function formatMessage(\stdClass $event) + { + $message = false; + + // Check for required properties. + if (isset($event->message, $event->variables)) { + // Messages without variables or user specified text. + if ($event->variables === 'N;') { + return $event->message; + } + + return $this->stringTranslation->translate( + $event->message, + unserialize($event->variables) + ); + } + + return $message; } - return $message; - } - - /** + /** * @param $dblog * @return array */ - protected function formatSingle($dblog) { - return array_combine($this->createTableHeader(), - $this->createTableRow($dblog)); - } - -} \ No newline at end of file + protected function formatSingle($dblog) + { + return array_combine( + $this->createTableHeader(), + $this->createTableRow($dblog) + ); + } +} diff --git a/src/Command/Database/DropCommand.php b/src/Command/Database/DropCommand.php index 66857dbc6..b5da63f21 100644 --- a/src/Command/Database/DropCommand.php +++ b/src/Command/Database/DropCommand.php @@ -34,7 +34,8 @@ class DropCommand extends Command * DropCommand constructor. * @param Connection $database */ - public function __construct(Connection $database) { + public function __construct(Connection $database) + { $this->database = $database; parent::__construct(); } diff --git a/src/Command/Database/DumpCommand.php b/src/Command/Database/DumpCommand.php index 349b44acd..5802eb5fa 100644 --- a/src/Command/Database/DumpCommand.php +++ b/src/Command/Database/DumpCommand.php @@ -125,22 +125,23 @@ protected function execute(InputInterface $input, OutputInterface $output) } if ($this->shellProcess->exec($command, $this->appRoot)) { - $resultFile = $file; - if ($gz) { - if(substr($file, -3) != '.gz') { - $resultFile = $file . ".gz"; - } - file_put_contents( - $resultFile, - gzencode( - file_get_contents( - $file) - ) - ); - if($resultFile != $file) { - unlink($file); - } - } + $resultFile = $file; + if ($gz) { + if (substr($file, -3) != '.gz') { + $resultFile = $file . ".gz"; + } + file_put_contents( + $resultFile, + gzencode( + file_get_contents( + $file + ) + ) + ); + if ($resultFile != $file) { + unlink($file); + } + } $io->success( sprintf( diff --git a/src/Command/Database/LogClearCommand.php b/src/Command/Database/LogClearCommand.php index 0aef41e82..58e7cae88 100644 --- a/src/Command/Database/LogClearCommand.php +++ b/src/Command/Database/LogClearCommand.php @@ -30,7 +30,8 @@ class LogClearCommand extends Command * LogClearCommand constructor. * @param Connection $database */ - public function __construct(Connection $database) { + public function __construct(Connection $database) + { $this->database = $database; parent::__construct(); } @@ -120,7 +121,7 @@ private function clearEvent(DrupalStyle $io, $eventId) } /** - * @param DrupalStyle $io + * @param DrupalStyle $io * @param $eventType * @param $eventSeverity * @param $userId diff --git a/src/Command/Database/LogDebugCommand.php b/src/Command/Database/LogDebugCommand.php index a643eb7d4..57ef7fe5b 100644 --- a/src/Command/Database/LogDebugCommand.php +++ b/src/Command/Database/LogDebugCommand.php @@ -19,156 +19,154 @@ * * @package Drupal\Console\Command\Database */ -class LogDebugCommand extends DatabaseLogBase { - - /** +class LogDebugCommand extends DatabaseLogBase +{ + /** * @var */ - protected $eventId; + protected $eventId; - /** + /** * @var */ - protected $asc; - /** + protected $asc; + /** * @var */ - protected $limit; - /** + protected $limit; + /** * @var */ - protected $offset; + protected $offset; - /** + /** * Print in yml style if true * * @var bool */ - protected $ymlStyle; + protected $ymlStyle; - /** + /** * {@inheritdoc} */ - protected function configure() { - $this - ->setName('database:log:debug') - ->setDescription($this->trans('commands.database.log.debug.description')); - - $this->addDefaultLoggingOptions(); - - $this - ->addArgument( - 'event-id', - InputArgument::OPTIONAL, - $this->trans('commands.database.log.debug.arguments.event-id') - ) - ->addOption( - 'asc', - FALSE, - InputOption::VALUE_NONE, - $this->trans('commands.database.log.debug.options.asc') - ) - ->addOption( - 'limit', - NULL, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.log.debug.options.limit') - ) - ->addOption( - 'offset', - NULL, - InputOption::VALUE_OPTIONAL, - $this->trans('commands.database.log.debug.options.offset'), - 0 - ) - ->addOption( - 'yml', - NULL, - InputOption::VALUE_NONE, - $this->trans('commands.database.log.debug.options.yml'), - NULL - ); - } - - /** + protected function configure() + { + $this + ->setName('database:log:debug') + ->setDescription($this->trans('commands.database.log.debug.description')); + + $this->addDefaultLoggingOptions(); + + $this + ->addArgument( + 'event-id', + InputArgument::OPTIONAL, + $this->trans('commands.database.log.debug.arguments.event-id') + ) + ->addOption( + 'asc', + false, + InputOption::VALUE_NONE, + $this->trans('commands.database.log.debug.options.asc') + ) + ->addOption( + 'limit', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.log.debug.options.limit') + ) + ->addOption( + 'offset', + null, + InputOption::VALUE_OPTIONAL, + $this->trans('commands.database.log.debug.options.offset'), + 0 + ) + ->addOption( + 'yml', + null, + InputOption::VALUE_NONE, + $this->trans('commands.database.log.debug.options.yml'), + null + ); + } + + /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) { - - $io = new DrupalStyle($input, $output); - - $this->getDefaultOptions($input); - $this->eventId = $input->getArgument('event-id'); - $this->asc = $input->getOption('asc'); - $this->limit = $input->getOption('limit'); - $this->offset = $input->getOption('offset'); - $this->ymlStyle = $input->getOption('yml'); - - - if ($this->eventId) { - return $this->getEventDetails($io); - } else { - return $this->getAllEvents($io); + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $this->getDefaultOptions($input); + $this->eventId = $input->getArgument('event-id'); + $this->asc = $input->getOption('asc'); + $this->limit = $input->getOption('limit'); + $this->offset = $input->getOption('offset'); + $this->ymlStyle = $input->getOption('yml'); + + + if ($this->eventId) { + return $this->getEventDetails($io); + } else { + return $this->getAllEvents($io); + } } - } - /** + /** * @param $io * @param $eventId * @return bool */ - private function getEventDetails(DrupalStyle $io) { - - $dblog = $this->database - ->query( - 'SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id', - [':id' => $this->eventId] - ) - ->fetchObject(); - - if (!$dblog) { - $io->error( - sprintf( - $this->trans('commands.database.log.debug.messages.not-found'), - $this->eventId - ) - ); - return 1; + private function getEventDetails(DrupalStyle $io) + { + $dblog = $this->database + ->query( + 'SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id', + [':id' => $this->eventId] + ) + ->fetchObject(); + + if (!$dblog) { + $io->error( + sprintf( + $this->trans('commands.database.log.debug.messages.not-found'), + $this->eventId + ) + ); + return 1; + } + + if ($this->ymlStyle) { + $io->writeln(Yaml::encode($this->formatSingle($dblog))); + } else { + $io->table( + $this->createTableHeader(), + [$this->createTableRow($dblog)] + ); + } } - if ($this->ymlStyle) { - $io->writeln(Yaml::encode($this->formatSingle($dblog))); - } else { - $io->table( - $this->createTableHeader(), - [$this->createTableRow($dblog)] - ); - } - - - } - - /** + /** * @param \Drupal\Console\Style\DrupalStyle $io * @return bool */ - private function getAllEvents(DrupalStyle $io) { + private function getAllEvents(DrupalStyle $io) + { + $query = $this->makeQuery($io); - $query = $this->makeQuery($io); + $result = $query->execute(); - $result = $query->execute(); + $tableRows = []; + foreach ($result as $dblog) { + $tableRows[] = $this->createTableRow($dblog); + } - $tableRows = []; - foreach ($result as $dblog) { - $tableRows[] = $this->createTableRow($dblog); - } - - $io->table( - $this->createTableHeader(), - $tableRows - ); - - return TRUE; - } + $io->table( + $this->createTableHeader(), + $tableRows + ); + return true; + } } diff --git a/src/Command/Database/LogPollCommand.php b/src/Command/Database/LogPollCommand.php index 8e80e020e..6ffd16bce 100644 --- a/src/Command/Database/LogPollCommand.php +++ b/src/Command/Database/LogPollCommand.php @@ -2,94 +2,87 @@ namespace Drupal\Console\Command\Database; - use Drupal\Console\Style\DrupalStyle; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; - /** * Class LogPollCommand * * @package Drupal\Console\Command\Database */ -class LogPollCommand extends DatabaseLogBase { - - /** +class LogPollCommand extends DatabaseLogBase +{ + /** * @var */ - protected $duration; + protected $duration; - /** + /** * */ - protected function configure() { - $this - ->setName('database:log:poll') - ->setDescription($this->trans('commands.database.log.poll.description')); - - $this->addDefaultLoggingOptions(); - - $this->addArgument( - 'duration', - InputArgument::OPTIONAL, - $this->trans('commands.database.log.poll.arguments.duration'), - '10' - ); - - } + protected function configure() + { + $this + ->setName('database:log:poll') + ->setDescription($this->trans('commands.database.log.poll.description')); + + $this->addDefaultLoggingOptions(); + + $this->addArgument( + 'duration', + InputArgument::OPTIONAL, + $this->trans('commands.database.log.poll.arguments.duration'), + '10' + ); + } - /** + /** * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output */ - protected function execute(InputInterface $input, OutputInterface $output) { - - $io = new DrupalStyle($input, $output); - - $io->note($this->trans('commands.database.log.poll.messages.warning')); + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); - $this->getDefaultOptions($input); - $this->duration = $input->getArgument('duration'); + $io->note($this->trans('commands.database.log.poll.messages.warning')); - $this->pollForEvents($io); + $this->getDefaultOptions($input); + $this->duration = $input->getArgument('duration'); - } + $this->pollForEvents($io); + } - /** + /** * @param \Drupal\Console\Style\DrupalStyle $io */ - protected function pollForEvents(DrupalStyle $io) { - - $query = $this->makeQuery($io)->countQuery(); - $results = $query->execute()->fetchAssoc(); - $count = $results['expression'] - 1;//minus 1 so the newest message always prints - - $tableHeader = $this->createTableHeader(); - - //Poll, force no wait on first loop - $lastExec = time() - $this->duration; - while (1) { - - if (time() > $lastExec + $this->duration) { - //Print out any new db logs - $query = $this->makeQuery($io, $count); - $results = $query->execute()->fetchAll(); - $count += count($results); - $tableRows = []; - foreach ($results as $r) { - $tableRows[] = $this->createTableRow($r); + protected function pollForEvents(DrupalStyle $io) + { + $query = $this->makeQuery($io)->countQuery(); + $results = $query->execute()->fetchAssoc(); + $count = $results['expression'] - 1;//minus 1 so the newest message always prints + + $tableHeader = $this->createTableHeader(); + + //Poll, force no wait on first loop + $lastExec = time() - $this->duration; + while (1) { + if (time() > $lastExec + $this->duration) { + //Print out any new db logs + $query = $this->makeQuery($io, $count); + $results = $query->execute()->fetchAll(); + $count += count($results); + $tableRows = []; + foreach ($results as $r) { + $tableRows[] = $this->createTableRow($r); + } + if (!empty($tableRows)) { + $io->table($tableHeader, $tableRows); + } + //update the last exec time + $lastExec = time(); + } } - if (!empty($tableRows)) { - $io->table($tableHeader, $tableRows); - } - //update the last exec time - $lastExec = time(); - } } - - } - - } diff --git a/src/Command/Database/QueryCommand.php b/src/Command/Database/QueryCommand.php index e32809675..6774e06ef 100644 --- a/src/Command/Database/QueryCommand.php +++ b/src/Command/Database/QueryCommand.php @@ -6,8 +6,8 @@ * * * @TODO: - * - mysql -H option for html - * - mysql -X option for xml + * - mysql -H option for html + * - mysql -X option for xml */ namespace Drupal\Console\Command\Database; @@ -70,49 +70,51 @@ protected function execute(InputInterface $input, OutputInterface $output) $databaseConnection = $this->resolveConnection($io, $database); - $connection = sprintf( - '%s -A --database=%s --user=%s --password=%s --host=%s --port=%s', - $databaseConnection['driver'], - $databaseConnection['database'], - $databaseConnection['username'], - $databaseConnection['password'], - $databaseConnection['host'], - $databaseConnection['port'] - ); - - $args = explode(' ', $connection); - $args[] = sprintf('--execute=%s', $query); - - $opts = ["quick", "debug", "html", "xml", "raw", "vertical", "batch"]; - array_walk($opts, function($opt) use ($input, &$args) { - if ($input->getOption($opt)) { - switch ($opt) { - case "quick": - $args[] = "--quick"; - break; - case "debug": - $args[] = "-T"; - break; - case "html": - $args[] = "-H"; - break; - case "xml": - $args[] = "-X"; - break; - case "raw": - $args[] = "--raw"; - break; - case "vertical": - $args[] = "-E"; - break; - case "batch": - $args[] = "--batch"; - break; - } - } - }); - - if ($learning) { + $connection = sprintf( + '%s -A --database=%s --user=%s --password=%s --host=%s --port=%s', + $databaseConnection['driver'], + $databaseConnection['database'], + $databaseConnection['username'], + $databaseConnection['password'], + $databaseConnection['host'], + $databaseConnection['port'] + ); + + $args = explode(' ', $connection); + $args[] = sprintf('--execute=%s', $query); + + $opts = ["quick", "debug", "html", "xml", "raw", "vertical", "batch"]; + array_walk( + $opts, function ($opt) use ($input, &$args) { + if ($input->getOption($opt)) { + switch ($opt) { + case "quick": + $args[] = "--quick"; + break; + case "debug": + $args[] = "-T"; + break; + case "html": + $args[] = "-H"; + break; + case "xml": + $args[] = "-X"; + break; + case "raw": + $args[] = "--raw"; + break; + case "vertical": + $args[] = "-E"; + break; + case "batch": + $args[] = "--batch"; + break; + } + } + } + ); + + if ($learning) { $io->commentBlock( implode(" ", $args) ); diff --git a/src/Command/Database/RestoreCommand.php b/src/Command/Database/RestoreCommand.php index a62f8ec77..3dc9d702a 100644 --- a/src/Command/Database/RestoreCommand.php +++ b/src/Command/Database/RestoreCommand.php @@ -31,7 +31,8 @@ class RestoreCommand extends Command * RestoreCommand constructor. * @param string $appRoot */ - public function __construct($appRoot) { + public function __construct($appRoot) + { $this->appRoot = $appRoot; parent::__construct(); } diff --git a/src/Command/Database/TableDebugCommand.php b/src/Command/Database/TableDebugCommand.php index 440357026..d8d80251a 100644 --- a/src/Command/Database/TableDebugCommand.php +++ b/src/Command/Database/TableDebugCommand.php @@ -39,7 +39,7 @@ class TableDebugCommand extends Command /** * TableDebugCommand constructor. - * @param R $redBean + * @param R $redBean * @param Connection $database */ public function __construct( diff --git a/src/Command/Develop/TranslationCleanupCommand.php b/src/Command/Develop/TranslationCleanupCommand.php index 938af4bf2..5fb3bac5f 100644 --- a/src/Command/Develop/TranslationCleanupCommand.php +++ b/src/Command/Develop/TranslationCleanupCommand.php @@ -25,7 +25,7 @@ class TranslationCleanupCommand extends Command /** * @var string */ - protected $consoleRoot; + protected $consoleRoot; /** * @var ConfigurationManager @@ -37,7 +37,6 @@ class TranslationCleanupCommand extends Command * * @param $consoleRoot * @param configurationManager $configurationManager - * */ public function __construct( $consoleRoot, @@ -103,21 +102,21 @@ protected function cleanupTranslations($io, $language = null, $languages) $finder = new Finder(); foreach ($languages as $langCode => $languageName) { - if (file_exists($this->consoleRoot . sprintf( DRUPAL_CONSOLE_LANGUAGE, $langCode ))) { - foreach ($finder->files()->name('*.yml')->in($this->consoleRoot . sprintf( DRUPAL_CONSOLE_LANGUAGE, $langCode )) as $file) { - $filename = $file->getBasename('.yml'); - if (!file_exists($this->consoleRoot . sprintf( DRUPAL_CONSOLE_LANGUAGE, 'en') . $filename . '.yml')) { - $io->info( - sprintf( - $this->trans('commands.translation.cleanup.messages.file-deleted'), - $filename, - $languageName - ) - ); - unlink($this->consoleRoot . sprintf( DRUPAL_CONSOLE_LANGUAGE, $langCode ). '/' . $filename . '.yml'); - } - } - } - } + if (file_exists($this->consoleRoot . sprintf(DRUPAL_CONSOLE_LANGUAGE, $langCode))) { + foreach ($finder->files()->name('*.yml')->in($this->consoleRoot . sprintf(DRUPAL_CONSOLE_LANGUAGE, $langCode)) as $file) { + $filename = $file->getBasename('.yml'); + if (!file_exists($this->consoleRoot . sprintf(DRUPAL_CONSOLE_LANGUAGE, 'en') . $filename . '.yml')) { + $io->info( + sprintf( + $this->trans('commands.translation.cleanup.messages.file-deleted'), + $filename, + $languageName + ) + ); + unlink($this->consoleRoot . sprintf(DRUPAL_CONSOLE_LANGUAGE, $langCode). '/' . $filename . '.yml'); + } + } + } + } } } diff --git a/src/Command/Develop/TranslationPendingCommand.php b/src/Command/Develop/TranslationPendingCommand.php index 559c7f079..0718b4fb5 100644 --- a/src/Command/Develop/TranslationPendingCommand.php +++ b/src/Command/Develop/TranslationPendingCommand.php @@ -29,7 +29,7 @@ class TranslationPendingCommand extends Command /** * @var string */ - protected $consoleRoot; + protected $consoleRoot; /** * @var ConfigurationManager @@ -47,8 +47,7 @@ class TranslationPendingCommand extends Command * * @param $consoleRoot * @param $configurationManager - * @param NestedArray $nestedArray - * + * @param NestedArray $nestedArray */ public function __construct( $consoleRoot, @@ -166,10 +165,10 @@ protected function determinePendingTranslation($io, $language = null, $languages foreach ($languages as $langCode => $languageName) { $languageDir = $this->consoleRoot . - sprintf( - DRUPAL_CONSOLE_LANGUAGE, - $langCode - ); + sprintf( + DRUPAL_CONSOLE_LANGUAGE, + $langCode + ); if (isset($language) && $langCode != $language) { continue; } diff --git a/src/Command/Develop/TranslationStatsCommand.php b/src/Command/Develop/TranslationStatsCommand.php index b26ed6f4c..e94a8a28c 100644 --- a/src/Command/Develop/TranslationStatsCommand.php +++ b/src/Command/Develop/TranslationStatsCommand.php @@ -30,7 +30,7 @@ class TranslationStatsCommand extends Command /** * @var string */ - protected $consoleRoot; + protected $consoleRoot; /** * @var ConfigurationManager @@ -52,8 +52,8 @@ class TranslationStatsCommand extends Command * * @param $appRoot * @param ConfigurationManager $configurationManager - * @param TwigRenderer $renderer - * @param NestedArray $nestedArray + * @param TwigRenderer $renderer + * @param NestedArray $nestedArray */ public function __construct( $consoleRoot, @@ -140,10 +140,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $io->writeln( $this->renderFile( - 'core/translation/stats.md.twig', - null, - $arguments - ) + 'core/translation/stats.md.twig', + null, + $arguments + ) ); } } @@ -175,12 +175,12 @@ protected function calculateStats($io, $language = null, $languages) foreach ($languages as $langCode => $languageName) { $languageDir = $this->consoleRoot . - sprintf( - DRUPAL_CONSOLE_LANGUAGE, - $langCode - ); - //don't show that language if that repo isn't present - if (!file_exists($languageDir)) { + sprintf( + DRUPAL_CONSOLE_LANGUAGE, + $langCode + ); + //don't show that language if that repo isn't present + if (!file_exists($languageDir)) { continue; } if (isset($language) && $langCode != $language) { diff --git a/src/Command/Develop/TranslationSyncCommand.php b/src/Command/Develop/TranslationSyncCommand.php index 1a87e6cdd..e96a76135 100644 --- a/src/Command/Develop/TranslationSyncCommand.php +++ b/src/Command/Develop/TranslationSyncCommand.php @@ -26,7 +26,7 @@ class TranslationSyncCommand extends Command /** * @var string */ - protected $consoleRoot; + protected $consoleRoot; /** * @var ConfigurationManager @@ -38,7 +38,6 @@ class TranslationSyncCommand extends Command * * @param $consoleRoot * @param configurationManager $configurationManager - * */ public function __construct( $consoleRoot, @@ -135,10 +134,10 @@ protected function syncTranslations($io, $language = null, $languages, $file) foreach ($languages as $langCode => $languageName) { $languageDir = $this->consoleRoot . - sprintf( - DRUPAL_CONSOLE_LANGUAGE, - $langCode - ); + sprintf( + DRUPAL_CONSOLE_LANGUAGE, + $langCode + ); if (isset($language) && $langCode != $language) { continue; } diff --git a/src/Command/Entity/DebugCommand.php b/src/Command/Entity/DebugCommand.php index d837049b1..905aabfb4 100644 --- a/src/Command/Entity/DebugCommand.php +++ b/src/Command/Entity/DebugCommand.php @@ -31,8 +31,8 @@ class DebugCommand extends Command /** * DeleteCommand constructor. - * @param EntityTypeRepository $entityTypeRepository - * @param EntityTypeManagerInterface $entityTypeManager + * @param EntityTypeRepository $entityTypeRepository + * @param EntityTypeManagerInterface $entityTypeManager */ public function __construct( EntityTypeRepository $entityTypeRepository, @@ -80,9 +80,9 @@ protected function execute(InputInterface $input, OutputInterface $output) $entityTypes = array_keys($entityTypesLabels); } - foreach($entityTypes as $entityTypeId){ + foreach ($entityTypes as $entityTypeId) { $entities = array_keys($entityTypesLabels[$entityTypeId]); - foreach($entities as $entity) { + foreach ($entities as $entity) { $tableRows[$entity] = [ $entity, $entityTypeId diff --git a/src/Command/Entity/DeleteCommand.php b/src/Command/Entity/DeleteCommand.php index 0bf875695..3933a103e 100644 --- a/src/Command/Entity/DeleteCommand.php +++ b/src/Command/Entity/DeleteCommand.php @@ -31,8 +31,8 @@ class DeleteCommand extends Command /** * DeleteCommand constructor. - * @param EntityTypeRepository $entityTypeRepository - * @param EntityTypeManagerInterface $entityTypeManager + * @param EntityTypeRepository $entityTypeRepository + * @param EntityTypeManagerInterface $entityTypeManager */ public function __construct( EntityTypeRepository $entityTypeRepository, diff --git a/src/Command/Features/DebugCommand.php b/src/Command/Features/DebugCommand.php index ee2dd49f8..617746a3e 100644 --- a/src/Command/Features/DebugCommand.php +++ b/src/Command/Features/DebugCommand.php @@ -1,77 +1,66 @@ setName('features:debug') - ->setDescription($this->trans('commands.features.debug.description')) - ->addArgument( - 'bundle', - InputArgument::OPTIONAL, - $this->trans('commands.features.debug.arguments.bundle') - ); - + $this + ->setName('features:debug') + ->setDescription($this->trans('commands.features.debug.description')) + ->addArgument( + 'bundle', + InputArgument::OPTIONAL, + $this->trans('commands.features.debug.arguments.bundle') + ); } protected function execute(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); - $bundle= $input->getArgument('bundle'); + $io = new DrupalStyle($input, $output); + $bundle= $input->getArgument('bundle'); - $tableHeader = [ - $this->trans('commands.features.debug.messages.bundle'), - $this->trans('commands.features.debug.messages.name'), - $this->trans('commands.features.debug.messages.machine_name'), - $this->trans('commands.features.debug.messages.status'), - $this->trans('commands.features.debug.messages.state'), - ]; + $tableHeader = [ + $this->trans('commands.features.debug.messages.bundle'), + $this->trans('commands.features.debug.messages.name'), + $this->trans('commands.features.debug.messages.machine_name'), + $this->trans('commands.features.debug.messages.status'), + $this->trans('commands.features.debug.messages.state'), + ]; - $tableRows = []; + $tableRows = []; - $features = $this->getFeatureList($bundle); + $features = $this->getFeatureList($io, $bundle); - foreach ($features as $feature) { - $tableRows[] = [$feature['bundle_name'],$feature['name'], $feature['machine_name'], $feature['status'],$feature['state']]; - } + foreach ($features as $feature) { + $tableRows[] = [$feature['bundle_name'],$feature['name'], $feature['machine_name'], $feature['status'],$feature['state']]; + } - $io->table($tableHeader, $tableRows, 'compact'); + $io->table($tableHeader, $tableRows, 'compact'); } - - - } +} diff --git a/src/Command/Features/ImportCommand.php b/src/Command/Features/ImportCommand.php index 9bf508ece..9823ac774 100644 --- a/src/Command/Features/ImportCommand.php +++ b/src/Command/Features/ImportCommand.php @@ -1,73 +1,68 @@ setName('features:import') - ->setDescription($this->trans('commands.features.import.description')) - ->addOption( - 'bundle', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.features.import.options.packages') - ) - ->addArgument('packages',InputArgument::IS_ARRAY,$this->trans('commands.features.import.arguments.packages')); - - + $this + ->setName('features:import') + ->setDescription($this->trans('commands.features.import.description')) + ->addOption( + 'bundle', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.features.import.options.packages') + ) + ->addArgument('packages', InputArgument::IS_ARRAY, $this->trans('commands.features.import.arguments.packages')); } protected function execute(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); + $io = new DrupalStyle($input, $output); - $packages = $input->getArgument('packages'); - $bundle = $input->getOption('bundle'); - - if ($bundle) { - $packages = $this->getPackagesByBundle($bundle); - } + $packages = $input->getArgument('packages'); + $bundle = $input->getOption('bundle'); - $this->getAssigner($bundle); - $this->importFeature($io,$packages); + if ($bundle) { + $packages = $this->getPackagesByBundle($bundle); + } + $this->getAssigner($bundle); + $this->importFeature($io, $packages); } + /** * {@inheritdoc} */ @@ -83,6 +78,5 @@ protected function interact(InputInterface $input, OutputInterface $output) $bundle = $this->packageQuestion($io); $input->setArgument('packages', $bundle); } - } - - } + } +} diff --git a/src/Command/Generate/AuthenticationProviderCommand.php b/src/Command/Generate/AuthenticationProviderCommand.php index 5888eadd2..f1ab59005 100644 --- a/src/Command/Generate/AuthenticationProviderCommand.php +++ b/src/Command/Generate/AuthenticationProviderCommand.php @@ -29,10 +29,14 @@ class AuthenticationProviderCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var AuthenticationProviderGenerator */ + /** + * @var AuthenticationProviderGenerator +*/ protected $generator; /** diff --git a/src/Command/Generate/BreakPointCommand.php b/src/Command/Generate/BreakPointCommand.php index 3720c0b4b..12785c393 100644 --- a/src/Command/Generate/BreakPointCommand.php +++ b/src/Command/Generate/BreakPointCommand.php @@ -52,7 +52,9 @@ class BreakPointCommand extends Command protected $themeHandler; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** @@ -74,7 +76,7 @@ public function __construct( ThemeHandler $themeHandler, Validator $validator, StringConverter $stringConverter - ) { + ) { $this->generator = $generator; $this->appRoot = $appRoot; $this->themeHandler = $themeHandler; diff --git a/src/Command/Generate/CommandCommand.php b/src/Command/Generate/CommandCommand.php index 860bb7f90..8efb20733 100644 --- a/src/Command/Generate/CommandCommand.php +++ b/src/Command/Generate/CommandCommand.php @@ -106,8 +106,7 @@ protected function configure() '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $this->trans('commands.common.options.services') - ) - ; + ); } /** diff --git a/src/Command/Generate/ControllerCommand.php b/src/Command/Generate/ControllerCommand.php index b3d4aafb2..53c6ba201 100644 --- a/src/Command/Generate/ControllerCommand.php +++ b/src/Command/Generate/ControllerCommand.php @@ -32,10 +32,14 @@ class ControllerCommand extends Command use InputTrait; use ContainerAwareCommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var ControllerGenerator */ + /** + * @var ControllerGenerator +*/ protected $generator; /** @@ -43,10 +47,14 @@ class ControllerCommand extends Command */ protected $stringConverter; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; - /** @var RouteProviderInterface */ + /** + * @var RouteProviderInterface +*/ protected $routeProvider; /** diff --git a/src/Command/Generate/EntityBundleCommand.php b/src/Command/Generate/EntityBundleCommand.php index 6f04b979c..a39f5a4be 100644 --- a/src/Command/Generate/EntityBundleCommand.php +++ b/src/Command/Generate/EntityBundleCommand.php @@ -34,10 +34,14 @@ class EntityBundleCommand extends Command */ protected $validator; - /** @var EntityBundleGenerator */ + /** + * @var EntityBundleGenerator +*/ protected $generator; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Command/Generate/FormAlterCommand.php b/src/Command/Generate/FormAlterCommand.php index 9699e2108..ea248c863 100644 --- a/src/Command/Generate/FormAlterCommand.php +++ b/src/Command/Generate/FormAlterCommand.php @@ -37,10 +37,14 @@ class FormAlterCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var FormAlterGenerator */ + /** + * @var FormAlterGenerator +*/ protected $generator; /** @@ -58,10 +62,14 @@ class FormAlterCommand extends Command */ protected $elementInfoManager; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; - /** @var RouteProviderInterface */ + /** + * @var RouteProviderInterface +*/ protected $routeProvider; /** @@ -309,5 +317,4 @@ public function getWebprofilerForms() } return $forms; } - } diff --git a/src/Command/Generate/FormCommand.php b/src/Command/Generate/FormCommand.php index ae570471b..a464211ca 100644 --- a/src/Command/Generate/FormCommand.php +++ b/src/Command/Generate/FormCommand.php @@ -35,13 +35,19 @@ abstract class FormCommand extends Command private $formType; private $commandName; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var FormGenerator */ + /** + * @var FormGenerator +*/ protected $generator; - /** @var ChainQueue */ + /** + * @var ChainQueue +*/ protected $chainQueue; /** diff --git a/src/Command/Generate/HelpCommand.php b/src/Command/Generate/HelpCommand.php index ad3616164..c71e21b3e 100644 --- a/src/Command/Generate/HelpCommand.php +++ b/src/Command/Generate/HelpCommand.php @@ -20,14 +20,15 @@ use Drupal\Console\Utils\Site; use Drupal\Console\Utils\ChainQueue; - class HelpCommand extends Command { use CommandTrait; use ModuleTrait; use ConfirmationTrait; - /** @var HelpGenerator */ + /** + * @var HelpGenerator +*/ protected $generator; /** @@ -35,7 +36,9 @@ class HelpCommand extends Command */ protected $site; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Command/Generate/ModuleCommand.php b/src/Command/Generate/ModuleCommand.php index 826e1986c..76605644a 100644 --- a/src/Command/Generate/ModuleCommand.php +++ b/src/Command/Generate/ModuleCommand.php @@ -28,10 +28,14 @@ class ModuleCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var ModuleGenerator */ + /** + * @var ModuleGenerator +*/ protected $generator; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** @@ -74,7 +78,7 @@ class ModuleCommand extends Command * @param DrupalApi $drupalApi * @param Client $httpClient * @param Site $site - * @param $twigtemplate + * @param $twigtemplate */ public function __construct( ModuleGenerator $generator, @@ -167,16 +171,16 @@ protected function configure() $this->trans('commands.generate.module.options.dependencies') ) ->addOption( - 'test', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.module.options.test') + 'test', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.module.options.test') ) ->addOption( - 'twigtemplate', - '', - InputOption::VALUE_OPTIONAL, - $this->trans('commands.generate.module.options.twigtemplate') + 'twigtemplate', + '', + InputOption::VALUE_OPTIONAL, + $this->trans('commands.generate.module.options.twigtemplate') ); } diff --git a/src/Command/Generate/ModuleFileCommand.php b/src/Command/Generate/ModuleFileCommand.php index dc089a8f2..a0457281d 100644 --- a/src/Command/Generate/ModuleFileCommand.php +++ b/src/Command/Generate/ModuleFileCommand.php @@ -18,7 +18,6 @@ use Drupal\Console\Extension\Manager; use Drupal\Console\Style\DrupalStyle; - /** * Class ModuleFileCommand * @package Drupal\Console\Command\Generate @@ -29,10 +28,14 @@ class ModuleFileCommand extends Command use ConfirmationTrait; use ModuleTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var ModuleFileGenerator */ + /** + * @var ModuleFileGenerator +*/ protected $generator; diff --git a/src/Command/Generate/PluginCKEditorButtonCommand.php b/src/Command/Generate/PluginCKEditorButtonCommand.php index b26f39aa3..cbae078de 100644 --- a/src/Command/Generate/PluginCKEditorButtonCommand.php +++ b/src/Command/Generate/PluginCKEditorButtonCommand.php @@ -33,10 +33,14 @@ class PluginCKEditorButtonCommand extends Command protected $chainQueue; - /** @var PluginCKEditorButtonGenerator */ + /** + * @var PluginCKEditorButtonGenerator +*/ protected $generator; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Command/Generate/PluginConditionCommand.php b/src/Command/Generate/PluginConditionCommand.php index f31e2e677..3aacc0922 100644 --- a/src/Command/Generate/PluginConditionCommand.php +++ b/src/Command/Generate/PluginConditionCommand.php @@ -21,7 +21,6 @@ use Drupal\Console\Utils\ChainQueue; use Drupal\Console\Utils\StringConverter; - /** * Class PluginConditionCommand * @package Drupal\Console\Command\Generate @@ -32,10 +31,14 @@ class PluginConditionCommand extends Command use ModuleTrait; use ConfirmationTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginConditionGenerator */ + /** + * @var PluginConditionGenerator +*/ protected $generator; /** @@ -51,11 +54,11 @@ class PluginConditionCommand extends Command /** * PluginConditionCommand constructor. - * @param Manager $extensionManager - * @param PluginConditionGenerator $generator - * @param ChainQueue $chainQueue - * @param EntityTypeRepository $entitytyperepository - * @param StringConverter $stringConverter + * @param Manager $extensionManager + * @param PluginConditionGenerator $generator + * @param ChainQueue $chainQueue + * @param EntityTypeRepository $entitytyperepository + * @param StringConverter $stringConverter */ public function __construct( Manager $extensionManager, diff --git a/src/Command/Generate/PluginFieldCommand.php b/src/Command/Generate/PluginFieldCommand.php index 468bc39b1..e49ef37fd 100644 --- a/src/Command/Generate/PluginFieldCommand.php +++ b/src/Command/Generate/PluginFieldCommand.php @@ -25,7 +25,9 @@ class PluginFieldCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Command/Generate/PluginFieldFormatterCommand.php b/src/Command/Generate/PluginFieldFormatterCommand.php index 3af94bee8..0e4d45485 100644 --- a/src/Command/Generate/PluginFieldFormatterCommand.php +++ b/src/Command/Generate/PluginFieldFormatterCommand.php @@ -31,10 +31,14 @@ class PluginFieldFormatterCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginFieldFormatterGenerator */ + /** + * @var PluginFieldFormatterGenerator +*/ protected $generator; /** @@ -42,7 +46,9 @@ class PluginFieldFormatterCommand extends Command */ protected $stringConverter; - /** @var FieldTypePluginManager */ + /** + * @var FieldTypePluginManager +*/ protected $fieldTypePluginManager; /** @@ -53,11 +59,11 @@ class PluginFieldFormatterCommand extends Command /** * PluginImageFormatterCommand constructor. - * @param Manager $extensionManager + * @param Manager $extensionManager * @param PluginFieldFormatterGenerator $generator - * @param StringConverter $stringConverter - * @param FieldTypePluginManager $fieldTypePluginManager - * @param ChainQueue $chainQueue + * @param StringConverter $stringConverter + * @param FieldTypePluginManager $fieldTypePluginManager + * @param ChainQueue $chainQueue */ public function __construct( Manager $extensionManager, diff --git a/src/Command/Generate/PluginFieldTypeCommand.php b/src/Command/Generate/PluginFieldTypeCommand.php index fb41ca55a..c9e99d15d 100644 --- a/src/Command/Generate/PluginFieldTypeCommand.php +++ b/src/Command/Generate/PluginFieldTypeCommand.php @@ -31,10 +31,14 @@ class PluginFieldTypeCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginFieldTypeGenerator */ + /** + * @var PluginFieldTypeGenerator +*/ protected $generator; /** diff --git a/src/Command/Generate/PluginFieldWidgetCommand.php b/src/Command/Generate/PluginFieldWidgetCommand.php index f43cda77f..fcdc4a20d 100644 --- a/src/Command/Generate/PluginFieldWidgetCommand.php +++ b/src/Command/Generate/PluginFieldWidgetCommand.php @@ -31,10 +31,14 @@ class PluginFieldWidgetCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginFieldWidgetGenerator */ + /** + * @var PluginFieldWidgetGenerator +*/ protected $generator; /** @@ -42,10 +46,14 @@ class PluginFieldWidgetCommand extends Command */ protected $stringConverter; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; - /** @var FieldTypePluginManager */ + /** + * @var FieldTypePluginManager +*/ protected $fieldTypePluginManager; /** diff --git a/src/Command/Generate/PluginImageEffectCommand.php b/src/Command/Generate/PluginImageEffectCommand.php index 6d4309dcd..c2fed7e30 100644 --- a/src/Command/Generate/PluginImageEffectCommand.php +++ b/src/Command/Generate/PluginImageEffectCommand.php @@ -30,10 +30,14 @@ class PluginImageEffectCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginImageEffectGenerator */ + /** + * @var PluginImageEffectGenerator +*/ protected $generator; /** diff --git a/src/Command/Generate/PluginImageFormatterCommand.php b/src/Command/Generate/PluginImageFormatterCommand.php index 1d56abbc5..8a30100d1 100644 --- a/src/Command/Generate/PluginImageFormatterCommand.php +++ b/src/Command/Generate/PluginImageFormatterCommand.php @@ -27,10 +27,14 @@ class PluginImageFormatterCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginImageFormatterGenerator */ + /** + * @var PluginImageFormatterGenerator +*/ protected $generator; /** @@ -38,7 +42,9 @@ class PluginImageFormatterCommand extends Command */ protected $stringConverter; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** @@ -49,11 +55,11 @@ class PluginImageFormatterCommand extends Command /** * PluginImageFormatterCommand constructor. - * @param Manager $extensionManager + * @param Manager $extensionManager * @param PluginImageFormatterGenerator $generator - * @param StringConverter $stringConverter - * @param Validator $validator - * @param ChainQueue $chainQueue + * @param StringConverter $stringConverter + * @param Validator $validator + * @param ChainQueue $chainQueue */ public function __construct( Manager $extensionManager, diff --git a/src/Command/Generate/PluginMailCommand.php b/src/Command/Generate/PluginMailCommand.php index 0eb67aa8d..254b50894 100644 --- a/src/Command/Generate/PluginMailCommand.php +++ b/src/Command/Generate/PluginMailCommand.php @@ -35,10 +35,14 @@ class PluginMailCommand extends Command use ConfirmationTrait; use ContainerAwareCommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginMailGenerator */ + /** + * @var PluginMailGenerator +*/ protected $generator; /** @@ -46,7 +50,9 @@ class PluginMailCommand extends Command */ protected $stringConverter; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** diff --git a/src/Command/Generate/PluginRestResourceCommand.php b/src/Command/Generate/PluginRestResourceCommand.php index 83327c3fa..bee7d0205 100644 --- a/src/Command/Generate/PluginRestResourceCommand.php +++ b/src/Command/Generate/PluginRestResourceCommand.php @@ -34,10 +34,14 @@ class PluginRestResourceCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginRestResourceGenerator */ + /** + * @var PluginRestResourceGenerator +*/ protected $generator; /** diff --git a/src/Command/Generate/PluginRulesActionCommand.php b/src/Command/Generate/PluginRulesActionCommand.php index c7ceb0ecc..76f596795 100644 --- a/src/Command/Generate/PluginRulesActionCommand.php +++ b/src/Command/Generate/PluginRulesActionCommand.php @@ -34,10 +34,14 @@ class PluginRulesActionCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginRulesActionGenerator */ + /** + * @var PluginRulesActionGenerator +*/ protected $generator; /** @@ -53,10 +57,10 @@ class PluginRulesActionCommand extends Command /** * PluginRulesActionCommand constructor. - * @param Manager $extensionManager - * @param PluginRulesActionGenerator $generator - * @param StringConverter $stringConverter - * @param ChainQueue $chainQueue + * @param Manager $extensionManager + * @param PluginRulesActionGenerator $generator + * @param StringConverter $stringConverter + * @param ChainQueue $chainQueue */ public function __construct( Manager $extensionManager, diff --git a/src/Command/Generate/PluginSkeletonCommand.php b/src/Command/Generate/PluginSkeletonCommand.php index b8a49a8b1..56367ffe7 100644 --- a/src/Command/Generate/PluginSkeletonCommand.php +++ b/src/Command/Generate/PluginSkeletonCommand.php @@ -33,10 +33,14 @@ class PluginSkeletonCommand extends Command use ServicesTrait; use ContainerAwareCommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginSkeletonGenerator */ + /** + * @var PluginSkeletonGenerator +*/ protected $generator; /** @@ -44,7 +48,9 @@ class PluginSkeletonCommand extends Command */ protected $stringConverter; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** diff --git a/src/Command/Generate/PluginTypeAnnotationCommand.php b/src/Command/Generate/PluginTypeAnnotationCommand.php index 1dabc927f..a84d5a5b7 100644 --- a/src/Command/Generate/PluginTypeAnnotationCommand.php +++ b/src/Command/Generate/PluginTypeAnnotationCommand.php @@ -21,7 +21,6 @@ use Drupal\Console\Extension\Manager; use Drupal\Console\Utils\StringConverter; - /** * Class PluginTypeAnnotationCommand * @package Drupal\Console\Command\Generate @@ -34,10 +33,14 @@ class PluginTypeAnnotationCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginTypeAnnotationGenerator */ + /** + * @var PluginTypeAnnotationGenerator +*/ protected $generator; /** diff --git a/src/Command/Generate/PluginTypeYamlCommand.php b/src/Command/Generate/PluginTypeYamlCommand.php index 0f366c314..686c91a53 100644 --- a/src/Command/Generate/PluginTypeYamlCommand.php +++ b/src/Command/Generate/PluginTypeYamlCommand.php @@ -34,10 +34,14 @@ class PluginTypeYamlCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginTypeYamlGenerator */ + /** + * @var PluginTypeYamlGenerator +*/ protected $generator; /** diff --git a/src/Command/Generate/PluginViewsFieldCommand.php b/src/Command/Generate/PluginViewsFieldCommand.php index d973725ee..44e879581 100644 --- a/src/Command/Generate/PluginViewsFieldCommand.php +++ b/src/Command/Generate/PluginViewsFieldCommand.php @@ -32,10 +32,14 @@ class PluginViewsFieldCommand extends Command use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PluginViewsFieldGenerator */ + /** + * @var PluginViewsFieldGenerator +*/ protected $generator; /** diff --git a/src/Command/Generate/PostUpdateCommand.php b/src/Command/Generate/PostUpdateCommand.php index 853a61f73..ec5f582e0 100644 --- a/src/Command/Generate/PostUpdateCommand.php +++ b/src/Command/Generate/PostUpdateCommand.php @@ -31,10 +31,14 @@ class PostUpdateCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var PostUpdateGenerator */ + /** + * @var PostUpdateGenerator +*/ protected $generator; /** @@ -42,7 +46,9 @@ class PostUpdateCommand extends Command */ protected $site; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** diff --git a/src/Command/Generate/ProfileCommand.php b/src/Command/Generate/ProfileCommand.php index 4df53d6b9..0abd64674 100644 --- a/src/Command/Generate/ProfileCommand.php +++ b/src/Command/Generate/ProfileCommand.php @@ -21,7 +21,6 @@ use Drupal\Console\Utils\Site; use GuzzleHttp\Client; - /** * Class ProfileCommand * @package Drupal\Console\Command\Generate @@ -32,10 +31,14 @@ class ProfileCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var ProfileGenerator */ + /** + * @var ProfileGenerator +*/ protected $generator; /** @@ -43,7 +46,9 @@ class ProfileCommand extends Command */ protected $stringConverter; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** diff --git a/src/Command/Generate/RouteSubscriberCommand.php b/src/Command/Generate/RouteSubscriberCommand.php index d3cabdcd3..f58a7c780 100644 --- a/src/Command/Generate/RouteSubscriberCommand.php +++ b/src/Command/Generate/RouteSubscriberCommand.php @@ -19,7 +19,6 @@ use Drupal\Console\Utils\ChainQueue; use Drupal\Console\Command\Shared\CommandTrait; - /** * Class RouteSubscriberCommand * @package Drupal\Console\Command\Generate @@ -30,10 +29,14 @@ class RouteSubscriberCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var RouteSubscriberGenerator */ + /** + * @var RouteSubscriberGenerator +*/ protected $generator; /** diff --git a/src/Command/Generate/ServiceCommand.php b/src/Command/Generate/ServiceCommand.php index 0c331dfdb..b31c7e2bb 100644 --- a/src/Command/Generate/ServiceCommand.php +++ b/src/Command/Generate/ServiceCommand.php @@ -32,10 +32,14 @@ class ServiceCommand extends Command use ConfirmationTrait; use ContainerAwareCommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var ServiceGenerator */ + /** + * @var ServiceGenerator +*/ protected $generator; /** @@ -50,10 +54,10 @@ class ServiceCommand extends Command /** * ServiceCommand constructor. - * @param Manager $extensionManager - * @param ServiceGenerator $generator - * @param StringConverter $stringConverter - * @param ChainQueue $chainQueue + * @param Manager $extensionManager + * @param ServiceGenerator $generator + * @param StringConverter $stringConverter + * @param ChainQueue $chainQueue */ public function __construct( Manager $extensionManager, diff --git a/src/Command/Generate/ThemeCommand.php b/src/Command/Generate/ThemeCommand.php index c77cb1677..b05b55c08 100644 --- a/src/Command/Generate/ThemeCommand.php +++ b/src/Command/Generate/ThemeCommand.php @@ -34,13 +34,19 @@ class ThemeCommand extends Command use ThemeBreakpointTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var ThemeGenerator */ + /** + * @var ThemeGenerator +*/ protected $generator; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; /** diff --git a/src/Command/Generate/TwigExtensionCommand.php b/src/Command/Generate/TwigExtensionCommand.php index b2e397d87..ed9529247 100644 --- a/src/Command/Generate/TwigExtensionCommand.php +++ b/src/Command/Generate/TwigExtensionCommand.php @@ -32,10 +32,14 @@ class TwigExtensionCommand extends Command use ConfirmationTrait; use ContainerAwareCommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var TwigExtensionGenerator */ + /** + * @var TwigExtensionGenerator +*/ protected $generator; /** diff --git a/src/Command/Generate/UpdateCommand.php b/src/Command/Generate/UpdateCommand.php index 0302b89ac..c65f89050 100644 --- a/src/Command/Generate/UpdateCommand.php +++ b/src/Command/Generate/UpdateCommand.php @@ -30,10 +30,14 @@ class UpdateCommand extends Command use ConfirmationTrait; use CommandTrait; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var UpdateGenerator */ + /** + * @var UpdateGenerator +*/ protected $generator; /** diff --git a/src/Command/Libraries/DebugCommand.php b/src/Command/Libraries/DebugCommand.php index 5b734e27a..8989b799c 100644 --- a/src/Command/Libraries/DebugCommand.php +++ b/src/Command/Libraries/DebugCommand.php @@ -22,16 +22,24 @@ class DebugCommand extends Command { use CommandTrait; - /** @var ModuleHandlerInterface */ + /** + * @var ModuleHandlerInterface +*/ protected $moduleHandler; - /** @var ThemeHandlerInterface; */ + /** + * @var ThemeHandlerInterface; +*/ protected $themeHandler; - /** @var LibraryDiscoveryInterface */ + /** + * @var LibraryDiscoveryInterface +*/ protected $libraryDiscovery; - /** @var string */ + /** + * @var string +*/ protected $appRoot; /** diff --git a/src/Command/Locale/LanguageDeleteCommand.php b/src/Command/Locale/LanguageDeleteCommand.php index 91a988a11..9cf290c4b 100644 --- a/src/Command/Locale/LanguageDeleteCommand.php +++ b/src/Command/Locale/LanguageDeleteCommand.php @@ -47,9 +47,9 @@ class LanguageDeleteCommand extends Command /** * LoginUrlCommand constructor. - * @param Site $site - * @param EntityTypeManagerInterface $entityTypeManager - * @param ModuleHandlerInterface $moduleHandler + * @param Site $site + * @param EntityTypeManagerInterface $entityTypeManager + * @param ModuleHandlerInterface $moduleHandler */ public function __construct( Site $site, diff --git a/src/Command/Migrate/ExecuteCommand.php b/src/Command/Migrate/ExecuteCommand.php index 4d327220c..b68586a08 100644 --- a/src/Command/Migrate/ExecuteCommand.php +++ b/src/Command/Migrate/ExecuteCommand.php @@ -119,7 +119,8 @@ protected function configure() '', InputOption::VALUE_OPTIONAL, $this->trans('commands.migrate.execute.options.source-base_path') - );; + ); + ; } /** diff --git a/src/Command/Module/DebugCommand.php b/src/Command/Module/DebugCommand.php index 6bed2f05c..59372172c 100644 --- a/src/Command/Module/DebugCommand.php +++ b/src/Command/Module/DebugCommand.php @@ -42,7 +42,7 @@ class DebugCommand extends Command /** * ChainDebugCommand constructor. * @param ConfigurationManager $configurationManager - * @param Site $site + * @param Site $site */ public function __construct( ConfigurationManager $configurationManager, diff --git a/src/Command/Module/DownloadCommand.php b/src/Command/Module/DownloadCommand.php index f214a0219..450db99fe 100644 --- a/src/Command/Module/DownloadCommand.php +++ b/src/Command/Module/DownloadCommand.php @@ -28,10 +28,14 @@ class DownloadCommand extends Command use CommandTrait; use ProjectDownloadTrait; - /** @var DrupalApi */ + /** + * @var DrupalApi +*/ protected $drupalApi; - /** @var Client */ + /** + * @var Client +*/ protected $httpClient; /** @@ -39,16 +43,24 @@ class DownloadCommand extends Command */ protected $appRoot; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; - /** @var ConfigurationManager */ + /** + * @var ConfigurationManager +*/ protected $configurationManager; - /** @var ShellProcess */ + /** + * @var ShellProcess +*/ protected $shellProcess; /** @@ -58,14 +70,14 @@ class DownloadCommand extends Command /** * DownloadCommand constructor. - * @param DrupalApi $drupalApi - * @param Client $httpClient + * @param DrupalApi $drupalApi + * @param Client $httpClient * @param $appRoot - * @param Manager $extensionManager - * @param Validator $validator - * @param Site $site + * @param Manager $extensionManager + * @param Validator $validator + * @param Site $site * @param ConfigurationManager $configurationManager - * @param ShellProcess $shellProcess + * @param ShellProcess $shellProcess * @param $root */ public function __construct( @@ -186,10 +198,11 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $version = $io->choice( sprintf( - $this->trans( - 'commands.site.new.questions.composer-release'), - $module - ), + $this->trans( + 'commands.site.new.questions.composer-release' + ), + $module + ), $versions ); } diff --git a/src/Command/Module/InstallCommand.php b/src/Command/Module/InstallCommand.php index b625221a5..039c3ecb6 100644 --- a/src/Command/Module/InstallCommand.php +++ b/src/Command/Module/InstallCommand.php @@ -40,16 +40,24 @@ class InstallCommand extends Command */ protected $site; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; - /** @var ModuleInstaller */ + /** + * @var ModuleInstaller +*/ protected $moduleInstaller; - /** @var DrupalApi */ + /** + * @var DrupalApi +*/ protected $drupalApi; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** @@ -64,13 +72,13 @@ class InstallCommand extends Command /** * InstallCommand constructor. - * @param Site $site - * @param Validator $validator + * @param Site $site + * @param Validator $validator * @param ModuleInstaller $moduleInstaller - * @param DrupalApi $drupalApi - * @param Manager $extensionManager + * @param DrupalApi $drupalApi + * @param Manager $extensionManager * @param $appRoot - * @param ChainQueue $chainQueue + * @param ChainQueue $chainQueue */ public function __construct( Site $site, @@ -157,12 +165,12 @@ protected function execute(InputInterface $input, OutputInterface $output) $processBuilder = new ProcessBuilder([]); $processBuilder->setWorkingDirectory($this->appRoot); - $processBuilder->setArguments(explode(" ", $command)); - $process = $processBuilder->getProcess(); - $process->setTty('true'); - $process->run(); + $processBuilder->setArguments(explode(" ", $command)); + $process = $processBuilder->getProcess(); + $process->setTty('true'); + $process->run(); - if ($process->isSuccessful()) { + if ($process->isSuccessful()) { $io->info( sprintf( 'Module %s was downloaded with Composer.', diff --git a/src/Command/Module/InstallDependencyCommand.php b/src/Command/Module/InstallDependencyCommand.php index e5e38fb7d..4bc60f4b0 100644 --- a/src/Command/Module/InstallDependencyCommand.php +++ b/src/Command/Module/InstallDependencyCommand.php @@ -36,10 +36,14 @@ class InstallDependencyCommand extends Command */ protected $site; - /** @var Validator */ + /** + * @var Validator +*/ protected $validator; - /** @var ModuleInstaller */ + /** + * @var ModuleInstaller +*/ protected $moduleInstaller; /** @@ -49,8 +53,8 @@ class InstallDependencyCommand extends Command /** * InstallCommand constructor. - * @param Site $site - * @param Validator $validator + * @param Site $site + * @param Validator $validator * @param ChainQueue $chainQueue */ public function __construct( diff --git a/src/Command/Module/UninstallCommand.php b/src/Command/Module/UninstallCommand.php index 030043ec8..ac42d2cfa 100755 --- a/src/Command/Module/UninstallCommand.php +++ b/src/Command/Module/UninstallCommand.php @@ -31,7 +31,9 @@ class UninstallCommand extends Command */ protected $site; - /** @var ModuleInstaller */ + /** + * @var ModuleInstaller +*/ protected $moduleInstaller; /** @@ -39,15 +41,17 @@ class UninstallCommand extends Command */ protected $chainQueue; - /** @var ConfigFactory */ + /** + * @var ConfigFactory +*/ protected $configFactory; /** * InstallCommand constructor. - * @param Site $site - * @param Validator $validator - * @param ChainQueue $chainQueue + * @param Site $site + * @param Validator $validator + * @param ChainQueue $chainQueue * @param ConfigFactory $configFactory */ public function __construct( @@ -55,7 +59,6 @@ public function __construct( ModuleInstaller $moduleInstaller, ChainQueue $chainQueue, ConfigFactory $configFactory - ) { $this->site = $site; $this->moduleInstaller = $moduleInstaller; @@ -199,7 +202,6 @@ protected function execute(InputInterface $input, OutputInterface $output) false ) ); - } catch (\Exception $e) { $io->error($e->getMessage()); diff --git a/src/Command/Module/UpdateCommand.php b/src/Command/Module/UpdateCommand.php index e3f034dc1..586e1ea7d 100644 --- a/src/Command/Module/UpdateCommand.php +++ b/src/Command/Module/UpdateCommand.php @@ -23,7 +23,9 @@ class UpdateCommand extends Command use ProjectDownloadTrait; - /** @var ShellProcess */ + /** + * @var ShellProcess +*/ protected $shellProcess; /** diff --git a/src/Command/Multisite/DebugCommand.php b/src/Command/Multisite/DebugCommand.php index a096b7c4d..aafac4269 100644 --- a/src/Command/Multisite/DebugCommand.php +++ b/src/Command/Multisite/DebugCommand.php @@ -27,7 +27,8 @@ class DebugCommand extends Command * DebugCommand constructor. * @param $appRoot */ - public function __construct($appRoot) { + public function __construct($appRoot) + { $this->appRoot = $appRoot; parent::__construct(); } diff --git a/src/Command/Multisite/NewCommand.php b/src/Command/Multisite/NewCommand.php index 1147f400c..374bd61e1 100644 --- a/src/Command/Multisite/NewCommand.php +++ b/src/Command/Multisite/NewCommand.php @@ -31,7 +31,8 @@ class NewCommand extends Command * DebugCommand constructor. * @param $appRoot */ - public function __construct($appRoot) { + public function __construct($appRoot) + { $this->appRoot = $appRoot; parent::__construct(); } diff --git a/src/Command/Node/AccessRebuildCommand.php b/src/Command/Node/AccessRebuildCommand.php index 3b71eef82..8d8e6c130 100644 --- a/src/Command/Node/AccessRebuildCommand.php +++ b/src/Command/Node/AccessRebuildCommand.php @@ -32,7 +32,8 @@ class AccessRebuildCommand extends Command * AccessRebuildCommand constructor. * @param StateInterface $state */ - public function __construct(StateInterface $state) { + public function __construct(StateInterface $state) + { $this->state = $state; parent::__construct(); } diff --git a/src/Command/PermissionDebugCommand.php b/src/Command/PermissionDebugCommand.php index 4ab2f3216..6afa4c8b0 100644 --- a/src/Command/PermissionDebugCommand.php +++ b/src/Command/PermissionDebugCommand.php @@ -65,32 +65,31 @@ protected function execute(InputInterface $input, OutputInterface $output) $io->table($tableHeader, array_values($tableRows)); return true; - } - else { + } else { $tableHeader = [ $this->trans('commands.permission.debug.table-headers.permission-name'), $this->trans('commands.permission.debug.table-headers.permission-label') ]; $tableRows = []; - $permissions = \Drupal::service('user.permissions')->getPermissions(); - $roles = user_roles(); - if (empty($roles[$role])) { - $message = sprintf($this->trans('commands.permission.debug.messages.role-error'), $role); - $io->error($message); - return true; - } - $user_permission = $roles[$role]->getPermissions(); - foreach ($permissions as $permission_name => $permission) { - if (in_array($permission_name, $user_permission)) { - $tableRows[$permission_name] = [ + $permissions = \Drupal::service('user.permissions')->getPermissions(); + $roles = user_roles(); + if (empty($roles[$role])) { + $message = sprintf($this->trans('commands.permission.debug.messages.role-error'), $role); + $io->error($message); + return true; + } + $user_permission = $roles[$role]->getPermissions(); + foreach ($permissions as $permission_name => $permission) { + if (in_array($permission_name, $user_permission)) { + $tableRows[$permission_name] = [ $permission_name, strip_tags($permission['title']->__toString()) - ]; - } - } - ksort($tableRows); - $io->table($tableHeader, array_values($tableRows)); - return true; + ]; + } + } + ksort($tableRows); + $io->table($tableHeader, array_values($tableRows)); + return true; } } @@ -103,13 +102,14 @@ protected function execute(InputInterface $input, OutputInterface $output) * @return array * User roles filtered by permission else empty array. */ - public function getRolesAssignedByPermission($permission_name) { + public function getRolesAssignedByPermission($permission_name) + { $roles = user_roles(); $roles_found = []; foreach ($roles as $role) { - if ($role->hasPermission($permission_name)) { - $roles_found[] = $role->getOriginalId(); - } + if ($role->hasPermission($permission_name)) { + $roles_found[] = $role->getOriginalId(); + } } return $roles_found; } diff --git a/src/Command/Queue/DebugCommand.php b/src/Command/Queue/DebugCommand.php index e30269254..fd2d050c2 100644 --- a/src/Command/Queue/DebugCommand.php +++ b/src/Command/Queue/DebugCommand.php @@ -31,7 +31,8 @@ class DebugCommand extends Command * DebugCommand constructor. * @param QueueWorkerManagerInterface $queueWorker */ - public function __construct( QueueWorkerManagerInterface $queueWorker) { + public function __construct(QueueWorkerManagerInterface $queueWorker) + { $this->queueWorker = $queueWorker; parent::__construct(); } diff --git a/src/Command/Queue/RunCommand.php b/src/Command/Queue/RunCommand.php index cc0052e8c..3185e4a70 100644 --- a/src/Command/Queue/RunCommand.php +++ b/src/Command/Queue/RunCommand.php @@ -37,8 +37,8 @@ class RunCommand extends Command /** * DebugCommand constructor. - * @param QueueWorkerManagerInterface $queueWorker - * @param QueueFactory $queue + * @param QueueWorkerManagerInterface $queueWorker + * @param QueueFactory $queue */ public function __construct( QueueWorkerManagerInterface $queueWorker, diff --git a/src/Command/Rest/DisableCommand.php b/src/Command/Rest/DisableCommand.php index d437491f5..bca821d26 100644 --- a/src/Command/Rest/DisableCommand.php +++ b/src/Command/Rest/DisableCommand.php @@ -125,8 +125,8 @@ protected function execute(InputInterface $input, OutputInterface $output) * @return string * The resource key in the form. */ - protected function getResourceKey($resource_id) { + protected function getResourceKey($resource_id) + { return str_replace(':', '.', $resource_id); } - } diff --git a/src/Command/Rest/EnableCommand.php b/src/Command/Rest/EnableCommand.php index 91ecad1fb..814a075c8 100644 --- a/src/Command/Rest/EnableCommand.php +++ b/src/Command/Rest/EnableCommand.php @@ -63,10 +63,10 @@ class EnableCommand extends Command /** * EnableCommand constructor. - * @param ResourcePluginManager $pluginManagerRest - * @param AuthenticationCollector $authenticationCollector - * @param ConfigFactory $configFactory - * @param array $formats + * @param ResourcePluginManager $pluginManagerRest + * @param AuthenticationCollector $authenticationCollector + * @param ConfigFactory $configFactory + * @param array $formats * The available serialization formats. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. @@ -162,11 +162,13 @@ protected function execute(InputInterface $input, OutputInterface $output) $format_resource_id = str_replace(':', '.', $resource_id); $config = $this->entityManager->getStorage('rest_resource_config')->load($format_resource_id); if (!$config) { - $config = $this->entityManager->getStorage('rest_resource_config')->create([ - 'id' => $format_resource_id, - 'granularity' => RestResourceConfigInterface::METHOD_GRANULARITY, - 'configuration' => [] - ]); + $config = $this->entityManager->getStorage('rest_resource_config')->create( + [ + 'id' => $format_resource_id, + 'granularity' => RestResourceConfigInterface::METHOD_GRANULARITY, + 'configuration' => [] + ] + ); } $configuration = $config->get('configuration') ?: []; $configuration[$method] = [ diff --git a/src/Command/Shared/ExportTrait.php b/src/Command/Shared/ExportTrait.php index 2a3f0aea5..508f8a203 100644 --- a/src/Command/Shared/ExportTrait.php +++ b/src/Command/Shared/ExportTrait.php @@ -32,7 +32,7 @@ protected function getConfiguration($configName, $uuid = false, $hash = false) // Exclude default_config_hash inside _core is site-specific. if ($hash) { - unset($config['_core']['default_config_hash']); + unset($config['_core']['default_config_hash']); } return $config; diff --git a/src/Command/Shared/FeatureTrait.php b/src/Command/Shared/FeatureTrait.php index 8f7f27002..04cdadf90 100644 --- a/src/Command/Shared/FeatureTrait.php +++ b/src/Command/Shared/FeatureTrait.php @@ -7,7 +7,6 @@ namespace Drupal\Console\Command\Shared; - use Drupal\Console\Style\DrupalStyle; use Symfony\Component\Console\Input\ArgvInput; use Drupal\features\FeaturesManagerInterface; @@ -22,220 +21,199 @@ */ trait FeatureTrait { + public function packageQuestion(DrupalStyle $io) + { + $packages = $this->getPackagesByBundle($bundle); + if (empty($packages)) { + throw new \Exception('No packages available'); + } - public function packageQuestion(DrupalStyle $io) - { - - $packages = $this->getPackagesByBundle($bundle); + $package = $io->choiceNoList( + $this->trans('commands.features.import.questions.packages'), + $packages + ); - if (empty($packages)) { - throw new \Exception('No packages available'); + return $package; } - $package = $io->choiceNoList( - $this->trans('commands.features.import.questions.packages'), - $packages - ); - - return $package; - - } - - /** + /** * @param bool $bundle_name * * @return \Drupal\features\FeaturesAssignerInterface */ - protected function getAssigner($bundle_name) { - /** @var \Drupal\features\FeaturesAssignerInterface $assigner */ - $assigner = \Drupal::service('features_assigner'); - if (!empty($bundle_name)) { - $bundle = $assigner->applyBundle($bundle_name); - - if ($bundle->getMachineName() != $bundle_name) { - - } - } - // return configuration for default bundle - else { - $assigner->assignConfigPackages(); + protected function getAssigner($bundle_name) + { + /** + * @var \Drupal\features\FeaturesAssignerInterface $assigner + */ + $assigner = \Drupal::service('features_assigner'); + if (!empty($bundle_name)) { + $bundle = $assigner->applyBundle($bundle_name); + + if ($bundle->getMachineName() != $bundle_name) { + } + } + // return configuration for default bundle + else { + $assigner->assignConfigPackages(); + } + return $assigner; } - return $assigner; - } - + /** + * Get a list of features. + * + * @param bundle + * + * @return features + */ + protected function getFeatureList($bundle) + { + $features = []; + $manager = $this->getFeatureManager(); + $modules = $this->getPackagesByBundle($bundle); + + foreach ($modules as $module_name) { + $feature = $manager->loadPackage($module_name, true); + $overrides = $manager->detectOverrides($feature); + + $state = $feature->getState(); + + if (!empty($overrides) && ($feature->getStatus() != FeaturesManagerInterface::STATUS_NO_EXPORT)) { + $state = FeaturesManagerInterface::STATE_OVERRIDDEN; + } + + if ($feature->getStatus() != FeaturesManagerInterface::STATUS_NO_EXPORT) { + $features[$feature->getMachineName()] = array( + 'name' => $feature->getName(), + 'machine_name' => $feature->getMachineName(), + 'bundle_name' => $feature->getBundle(), + 'status' => $manager->statusLabel($feature->getStatus()), + 'state' => ($state != FeaturesManagerInterface::STATE_DEFAULT) ? $manager->stateLabel($state) : '', + ); + } + } - /** - * Get a list of features. - * - * @param bundle - * - * @return features - */ - protected function getFeatureList($io,$bundle) { - - $features = []; - $manager = $this->getFeatureManager(); - $modules = $this->getPackagesByBundle($bundle); - - foreach ($modules as $module_name) { - $feature = $manager->loadPackage($module_name,TRUE); - $overrides = $manager->detectOverrides($feature); - - $state = $feature->getState(); - - if (!empty($overrides) && ($feature->getStatus() != FeaturesManagerInterface::STATUS_NO_EXPORT)) { - $state = FeaturesManagerInterface::STATE_OVERRIDDEN; - } - - if ($feature->getStatus() != FeaturesManagerInterface::STATUS_NO_EXPORT) { - - $features[$feature->getMachineName()] = array( - 'name' => $feature->getName(), - 'machine_name' => $feature->getMachineName(), - 'bundle_name' => $feature->getBundle(), - 'status' => $manager->statusLabel($feature->getStatus()), - 'state' => ($state != FeaturesManagerInterface::STATE_DEFAULT) - ? $manager->stateLabel($state) - : '', - ); - } - + return $features; } - return $features; - - } - - protected function importFeature($io,$packages) { - - $manager = $this->getFeatureManager(); - - /** @var \Drupal\config_update\ConfigRevertInterface $config_revert */ - $config_revert = \Drupal::service('features.config_update'); - - $config = $manager->getConfigCollection(); - $modules = (is_array($packages)) ? $packages : array($packages); - $overridden = [] ; - foreach ($modules as $module_name) { - - $package = $manager->loadPackage($module_name,TRUE); - - if (empty($package)) { - $io->warning( - sprintf( - $this->trans('commands.features.import.messages.not-available'), - $module_name - ) - ); - continue; - } - - if ($package->getStatus() != FeaturesManagerInterface::STATUS_INSTALLED) { - $io->warning( - sprintf( - $this->trans('commands.features.import.messages.uninstall'), - $module_name - ) - ); - continue; - } - - $overrides = $manager->detectOverrides($package); - $missing = $manager->reorderMissing($manager->detectMissing($package)); - - if (!empty($overrides) || !empty($missing) && ($package->getStatus() == FeaturesManagerInterface::STATUS_INSTALLED)) { - $overridden[] = array_merge($missing,$overrides); - } - } + protected function importFeature($io, $packages) + { + $manager = $this->getFeatureManager(); + + $modules = (is_array($packages)) ? $packages : array($packages); + $overridden = [] ; + foreach ($modules as $module_name) { + $package = $manager->loadPackage($module_name, true); + + if (empty($package)) { + $io->warning( + sprintf( + $this->trans('commands.features.import.messages.not-available'), + $module_name + ) + ); + continue; + } + + if ($package->getStatus() != FeaturesManagerInterface::STATUS_INSTALLED) { + $io->warning( + sprintf( + $this->trans('commands.features.import.messages.uninstall'), + $module_name + ) + ); + continue; + } + + $overrides = $manager->detectOverrides($package); + $missing = $manager->reorderMissing($manager->detectMissing($package)); + + if (!empty($overrides) || !empty($missing) && ($package->getStatus() == FeaturesManagerInterface::STATUS_INSTALLED)) { + $overridden[] = array_merge($missing, $overrides); + } + } - // Process only missing or overriden features - $components = $overridden; + // Process only missing or overriden features + $components = $overridden; - if (empty($components)){ - $io->warning( - sprintf( - $this->trans('commands.features.import.messages.nothing'), - $components - ) - ); + if (empty($components)) { + $io->warning( + sprintf( + $this->trans('commands.features.import.messages.nothing'), + $components + ) + ); - return ; + return ; + } else { + $this->import($io, $components); + } } - else { - $this->import($io,$components); + public function import($io, $components) + { + $manager = $this->getFeatureManager(); + /** + * @var \Drupal\config_update\ConfigRevertInterface $config_revert + */ + $config_revert = \Drupal::service('features.config_update'); + + $config = $manager->getConfigCollection(); + + foreach ($components as $component) { + foreach ($component as $feature) { + if (!isset($config[$feature])) { + + //Import missing component. + $item = $manager->getConfigType($feature); + $type = ConfigurationItem::fromConfigStringToConfigType($item['type']); + $config_revert->import($type, $item['name_short']); + $io->info( + sprintf( + $this->trans('commands.features.import.messages.importing'), + $feature + ) + ); + } else { + + // Revert existing component. + $item = $config[$feature]; + $type = ConfigurationItem::fromConfigStringToConfigType($item->getType()); + $config_revert->revert($type, $item->getShortName()); + $io->info( + sprintf( + $this->trans('commands.features.import.messages.reverting'), + $feature + ) + ); + } + } + } } - } - - public function import($io,$components) { - $manager = $this->getFeatureManager(); - /** @var \Drupal\config_update\ConfigRevertInterface $config_revert */ - $config_revert = \Drupal::service('features.config_update'); - $config = $manager->getConfigCollection(); - foreach ($components as $component) { - foreach ($component as $feature) { - - if (!isset($config[$feature])) { - - //Import missing component. - $item = $manager->getConfigType($feature); - $type = ConfigurationItem::fromConfigStringToConfigType($item['type']); - $config_revert->import($type, $item['name_short']); - $io->info( - sprintf( - $this->trans('commands.features.import.messages.importing'), - $feature - ) - ); + public function getPackagesByBundle($bundle) + { + $manager = $this->getFeatureManager(); + $assigner = $this->getAssigner($bundle); + $current_bundle = $assigner->getBundle(); + // List all packages availables + if ($current_bundle->getMachineName() == 'default') { + $current_bundle = null; } - else { + $packages = array_keys($manager->getFeaturesModules($current_bundle)); - // Revert existing component. - $item = $config[$feature]; - $type = ConfigurationItem::fromConfigStringToConfigType($item->getType()); - $config_revert->revert($type, $item->getShortName()); - $io->info( - sprintf( - $this->trans('commands.features.import.messages.reverting'), - $feature - ) - ); - } - } + return $packages; } - } - - - public function getPackagesByBundle($bundle) { - - $packages = []; - $manager = $this->getFeatureManager(); - $assigner = $this->getAssigner($bundle); - $current_bundle = $assigner->getBundle(); - - // List all packages availables - if ($current_bundle->getMachineName() == 'default') { - $current_bundle = NULL; - + public function getFeatureManager() + { + return \Drupal::service('features.manager'); } - - $packages = array_keys($manager->getFeaturesModules($current_bundle)); - - return $packages; - - } - - public function getFeatureManager(){ - return \Drupal::service('features.manager'); - } - } diff --git a/src/Command/Shared/MigrationTrait.php b/src/Command/Shared/MigrationTrait.php index 82077c27d..94f5499c8 100644 --- a/src/Command/Shared/MigrationTrait.php +++ b/src/Command/Shared/MigrationTrait.php @@ -29,9 +29,11 @@ trait MigrationTrait protected function getMigrations($version_tag = false, $flatList = false, $configuration = []) { //Get migration definitions by tag - $migrations = array_filter($this->pluginManagerMigration->getDefinitions(), function($migration) use ($version_tag) { - return !empty($migration['migration_tags']) && in_array($version_tag, $migration['migration_tags']); - }); + $migrations = array_filter( + $this->pluginManagerMigration->getDefinitions(), function ($migration) use ($version_tag) { + return !empty($migration['migration_tags']) && in_array($version_tag, $migration['migration_tags']); + } + ); // Create an array to configure all migration plugins with same configuration $keys = array_keys($migrations); diff --git a/src/Command/Site/InstallCommand.php b/src/Command/Site/InstallCommand.php index 5907664bd..94423b957 100644 --- a/src/Command/Site/InstallCommand.php +++ b/src/Command/Site/InstallCommand.php @@ -26,7 +26,6 @@ use Drupal\Console\Utils\Site; use DrupalFinder\DrupalFinder; - class InstallCommand extends Command { use ContainerAwareCommandTrait; @@ -374,8 +373,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $io = new DrupalStyle($input, $output); $uri = parse_url($input->getParameterOption(['--uri', '-l']) ?: 'default', PHP_URL_HOST); - if($this->site->multisiteMode($uri)) { - if(!$this->site->validMultisite($uri)) { + if ($this->site->multisiteMode($uri)) { + if (!$this->site->validMultisite($uri)) { $io->error( sprintf($this->trans('commands.site.install.messages.invalid-multisite'), $uri, $uri) ); @@ -433,7 +432,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } try { - $drupalFinder = new DrupalFinder(); $drupalFinder->locateRoot(getcwd()); $composerRoot = $drupalFinder->getComposerRoot(); @@ -445,7 +443,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $drupal = new Drupal($autoload, $composerRoot, $drupalRoot); $container = $drupal->boot(); $this->getApplication()->setContainer($container); - } catch (Exception $e) { $io->error($e->getMessage()); return; @@ -495,8 +492,7 @@ protected function runInstaller( InputInterface $input, $database, $uri - ) - { + ) { $this->site->loadLegacyFile('/core/includes/install.core.inc'); $driver = (string)$database['driver']; diff --git a/src/Command/Site/MaintenanceCommand.php b/src/Command/Site/MaintenanceCommand.php index dfc49617a..e562a0df9 100644 --- a/src/Command/Site/MaintenanceCommand.php +++ b/src/Command/Site/MaintenanceCommand.php @@ -34,8 +34,8 @@ class MaintenanceCommand extends Command /** * DebugCommand constructor. - * @param StateInterface $state - * @param ChainQueue $chainQueue + * @param StateInterface $state + * @param ChainQueue $chainQueue */ public function __construct( StateInterface $state, diff --git a/src/Command/Site/ModeCommand.php b/src/Command/Site/ModeCommand.php index f39b6dd78..b70e42442 100644 --- a/src/Command/Site/ModeCommand.php +++ b/src/Command/Site/ModeCommand.php @@ -21,7 +21,6 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\Console\Utils\ChainQueue; - class ModeCommand extends Command { use ContainerAwareCommandTrait; @@ -222,9 +221,7 @@ protected function overrideConfigurations($configurations, $io) // include settings.local.php in settings.php // -- check first line if it is already this - if ( - $this->maginot->getFirstLine($this->settings_file) - != $line_include_settings + if ($this->maginot->getFirstLine($this->settings_file)!= $line_include_settings ) { chmod($this->settings_file, (int)0775); $this->maginot->setFirstLine( @@ -244,10 +241,7 @@ protected function overrideConfigurations($configurations, $io) if (!$this->local) { // comment local.settings.php in settings.php - if ( - $this->maginot->getFirstLine($this->settings_file) - == - $line_include_settings + if ($this->maginot->getFirstLine($this->settings_file)==$line_include_settings ) { $this->maginot->deleteFirstLine( $this->settings_file @@ -263,7 +257,7 @@ protected function overrideConfigurations($configurations, $io) } catch (IOExceptionInterface $e) { echo $e->getMessage(); } - }else{ + } else { // comment cache bins in local.settings.php, // we still use local.settings.php for testing PROD @@ -282,10 +276,7 @@ protected function overrideConfigurations($configurations, $io) } /** - * * would be better if this were replaced by $config->save? - * - * */ //@TODO: 0444 should be a better permission for settings.php chmod($this->settings_file, (int)0644); diff --git a/src/Command/Site/StatisticsCommand.php b/src/Command/Site/StatisticsCommand.php index 6fe46d027..be80636f1 100644 --- a/src/Command/Site/StatisticsCommand.php +++ b/src/Command/Site/StatisticsCommand.php @@ -47,10 +47,10 @@ class StatisticsCommand extends Command /** * StatisticsCommand constructor. - * @param DrupalApi $drupalApi - * @param QueryFactory $entityQuery; - * @param Manager $extensionManager - * @param ModuleHandlerInterface $moduleHandler + * @param DrupalApi $drupalApi + * @param QueryFactory $entityQuery; + * @param Manager $extensionManager + * @param ModuleHandlerInterface $moduleHandler */ public function __construct( DrupalApi $drupalApi, diff --git a/src/Command/Site/StatusCommand.php b/src/Command/Site/StatusCommand.php index a764625c0..453a3d1cf 100644 --- a/src/Command/Site/StatusCommand.php +++ b/src/Command/Site/StatusCommand.php @@ -72,8 +72,8 @@ class StatusCommand extends Command /** * DebugCommand constructor. - * @param SystemManager $systemManager - * @param Settings $settings + * @param SystemManager $systemManager + * @param Settings $settings * @param ConfigFactory $configFactory * @param ThemeHandler $themeHandler * @param $appRoot @@ -213,7 +213,6 @@ protected function getThemeData() protected function getDirectoryData() { - $systemTheme = $this->configFactory->get('system.theme'); $themeDefaultDirectory = ''; diff --git a/src/Command/Taxonomy/DeleteTermCommand.php b/src/Command/Taxonomy/DeleteTermCommand.php index 5dfdb8fad..bb3f996b4 100644 --- a/src/Command/Taxonomy/DeleteTermCommand.php +++ b/src/Command/Taxonomy/DeleteTermCommand.php @@ -32,7 +32,8 @@ class DeleteTermCommand extends Command * InfoCommand constructor. * @param EntityTypeManagerInterface $entityTypeManager */ - public function __construct(EntityTypeManagerInterface $entityTypeManager) { + public function __construct(EntityTypeManagerInterface $entityTypeManager) + { $this->entityTypeManager = $entityTypeManager; parent::__construct(); } @@ -70,8 +71,8 @@ private function deleteExistingTerms($vid = null, DrupalStyle $io) { //Load the vid $termStorage = $this->entityTypeManager->getStorage('taxonomy_term'); - $vocabularies = $this->entityTypeManager->getStorage('taxonomy_vocabulary') - ->loadMultiple(); + $vocabularies = $this->entityTypeManager->getStorage('taxonomy_vocabulary') + ->loadMultiple(); if ($vid !== 'all') { $vid = [$vid]; diff --git a/src/Command/Test/DebugCommand.php b/src/Command/Test/DebugCommand.php index 24470bab0..32fef1cd6 100644 --- a/src/Command/Test/DebugCommand.php +++ b/src/Command/Test/DebugCommand.php @@ -35,7 +35,7 @@ class DebugCommand extends Command /** * DebugCommand constructor. - * @param TestDiscovery $test_discovery + * @param TestDiscovery $test_discovery */ public function __construct( TestDiscovery $test_discovery diff --git a/src/Command/Test/RunCommand.php b/src/Command/Test/RunCommand.php index ba882d005..2b945057b 100644 --- a/src/Command/Test/RunCommand.php +++ b/src/Command/Test/RunCommand.php @@ -56,9 +56,9 @@ class RunCommand extends Command /** * RunCommand constructor. - * @param Site $site - * @param TestDiscovery $test_discovery - * @param ModuleHandlerInterface $moduleHandler + * @param Site $site + * @param TestDiscovery $test_discovery + * @param ModuleHandlerInterface $moduleHandler */ public function __construct( $appRoot, diff --git a/src/Command/Theme/DebugCommand.php b/src/Command/Theme/DebugCommand.php index 695956909..c0fd81674 100644 --- a/src/Command/Theme/DebugCommand.php +++ b/src/Command/Theme/DebugCommand.php @@ -33,7 +33,7 @@ class DebugCommand extends Command /** * DebugCommand constructor. * @param ConfigFactory $configFactory - * @param ThemeHandler $themeHandler + * @param ThemeHandler $themeHandler */ public function __construct( ConfigFactory $configFactory, diff --git a/src/Command/Theme/DownloadCommand.php b/src/Command/Theme/DownloadCommand.php index c111e6d5e..c3e3919b1 100644 --- a/src/Command/Theme/DownloadCommand.php +++ b/src/Command/Theme/DownloadCommand.php @@ -42,8 +42,8 @@ class DownloadCommand extends Command /** * DownloadCommand constructor. - * @param DrupalApi $drupalApi - * @param Client $httpClient + * @param DrupalApi $drupalApi + * @param Client $httpClient * @param $appRoot */ public function __construct( diff --git a/src/Command/Theme/InstallCommand.php b/src/Command/Theme/InstallCommand.php index 893cf0b04..f6ba43e6d 100644 --- a/src/Command/Theme/InstallCommand.php +++ b/src/Command/Theme/InstallCommand.php @@ -41,8 +41,8 @@ class InstallCommand extends Command /** * DebugCommand constructor. * @param ConfigFactory $configFactory - * @param ThemeHandler $themeHandler - * @param ChainQueue $chainQueue + * @param ThemeHandler $themeHandler + * @param ChainQueue $chainQueue */ public function __construct( ConfigFactory $configFactory, diff --git a/src/Command/Theme/UninstallCommand.php b/src/Command/Theme/UninstallCommand.php index 8d11fffa2..a22e3d7c4 100644 --- a/src/Command/Theme/UninstallCommand.php +++ b/src/Command/Theme/UninstallCommand.php @@ -40,8 +40,8 @@ class UninstallCommand extends Command /** * DebugCommand constructor. * @param ConfigFactory $configFactory - * @param ThemeHandler $themeHandler - * @param ChainQueue $chainQueue + * @param ThemeHandler $themeHandler + * @param ChainQueue $chainQueue */ public function __construct( ConfigFactory $configFactory, diff --git a/src/Command/Update/EntitiesCommand.php b/src/Command/Update/EntitiesCommand.php index 43ea2aed0..521bb6e0f 100644 --- a/src/Command/Update/EntitiesCommand.php +++ b/src/Command/Update/EntitiesCommand.php @@ -44,7 +44,7 @@ class EntitiesCommand extends Command /** * EntitiesCommand constructor. - * @param StateInterface $state + * @param StateInterface $state * @param EntityDefinitionUpdateManager $entityDefinitionUpdateManager * @param ChainQueue $chainQueue */ diff --git a/src/Command/Update/ExecuteCommand.php b/src/Command/Update/ExecuteCommand.php index ccfba07ec..d84d78b4a 100644 --- a/src/Command/Update/ExecuteCommand.php +++ b/src/Command/Update/ExecuteCommand.php @@ -45,7 +45,9 @@ class ExecuteCommand extends Command protected $postUpdateRegistry; - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** @@ -66,10 +68,10 @@ class ExecuteCommand extends Command /** * EntitiesCommand constructor. * @param Site $site - * @param StateInterface $state + * @param StateInterface $state * @param ModuleHandler $moduleHandler * @param UpdateRegistry $postUpdateRegistry - * @param Manager $extensionManager + * @param Manager $extensionManager * @param ChainQueue $chainQueue */ public function __construct( diff --git a/src/Command/User/CreateCommand.php b/src/Command/User/CreateCommand.php index c19639729..797b370d9 100644 --- a/src/Command/User/CreateCommand.php +++ b/src/Command/User/CreateCommand.php @@ -48,10 +48,10 @@ class CreateCommand extends Command /** * CreateCommand constructor. - * @param Connection $database - * @param EntityTypeManagerInterface $entityTypeManager - * @param DateFormatterInterface $dateFormatter - * @param DrupalApi $drupalApi + * @param Connection $database + * @param EntityTypeManagerInterface $entityTypeManager + * @param DateFormatterInterface $dateFormatter + * @param DrupalApi $drupalApi */ public function __construct( Connection $database, diff --git a/src/Command/User/DebugCommand.php b/src/Command/User/DebugCommand.php index 450224bc0..b03222e3c 100644 --- a/src/Command/User/DebugCommand.php +++ b/src/Command/User/DebugCommand.php @@ -43,8 +43,8 @@ class DebugCommand extends Command /** * DebugCommand constructor. * @param EntityTypeManagerInterface $entityTypeManager - * @param QueryFactory $entityQuery - * @param DrupalApi $drupalApi + * @param QueryFactory $entityQuery + * @param DrupalApi $drupalApi */ public function __construct( EntityTypeManagerInterface $entityTypeManager, diff --git a/src/Command/User/DeleteCommand.php b/src/Command/User/DeleteCommand.php index d01d327d4..4c0611ce4 100644 --- a/src/Command/User/DeleteCommand.php +++ b/src/Command/User/DeleteCommand.php @@ -43,8 +43,8 @@ class DeleteCommand extends Command /** * DeleteCommand constructor. * @param EntityTypeManagerInterface $entityTypeManager - * @param QueryFactory $entityQuery - * @param DrupalApi $drupalApi + * @param QueryFactory $entityQuery + * @param DrupalApi $drupalApi */ public function __construct( EntityTypeManagerInterface $entityTypeManager, diff --git a/src/Command/User/LoginCleanAttemptsCommand.php b/src/Command/User/LoginCleanAttemptsCommand.php index 93ca05fc5..6ca7e66ea 100644 --- a/src/Command/User/LoginCleanAttemptsCommand.php +++ b/src/Command/User/LoginCleanAttemptsCommand.php @@ -31,7 +31,8 @@ class LoginCleanAttemptsCommand extends Command * LoginCleanAttemptsCommand constructor. * @param Connection $database */ - public function __construct(Connection $database) { + public function __construct(Connection $database) + { $this->database = $database; parent::__construct(); } diff --git a/src/Command/User/LoginUrlCommand.php b/src/Command/User/LoginUrlCommand.php index ac2550f23..3edfb1850 100644 --- a/src/Command/User/LoginUrlCommand.php +++ b/src/Command/User/LoginUrlCommand.php @@ -31,9 +31,10 @@ class LoginUrlCommand extends Command /** * LoginUrlCommand constructor. - * @param EntityTypeManagerInterface $entityTypeManager + * @param EntityTypeManagerInterface $entityTypeManager */ - public function __construct(EntityTypeManagerInterface $entityTypeManager) { + public function __construct(EntityTypeManagerInterface $entityTypeManager) + { $this->entityTypeManager = $entityTypeManager; parent::__construct(); } diff --git a/src/Command/User/PasswordHashCommand.php b/src/Command/User/PasswordHashCommand.php index 795c9e410..c31044cee 100644 --- a/src/Command/User/PasswordHashCommand.php +++ b/src/Command/User/PasswordHashCommand.php @@ -30,7 +30,8 @@ class PasswordHashCommand extends Command * PasswordHashCommand constructor. * @param PasswordInterface $password */ - public function __construct(PasswordInterface $password) { + public function __construct(PasswordInterface $password) + { $this->password = $password; parent::__construct(); } diff --git a/src/Command/User/RoleCommand.php b/src/Command/User/RoleCommand.php index a4f7c0b23..9d9f75231 100644 --- a/src/Command/User/RoleCommand.php +++ b/src/Command/User/RoleCommand.php @@ -32,7 +32,8 @@ class RoleCommand extends Command * RoleCommand constructor. * @param DrupalApi $drupalApi */ - public function __construct(DrupalApi $drupalApi) { + public function __construct(DrupalApi $drupalApi) + { $this->drupalApi = $drupalApi; parent::__construct(); } diff --git a/src/Command/Views/DebugCommand.php b/src/Command/Views/DebugCommand.php index 8e60acc24..1b261337f 100644 --- a/src/Command/Views/DebugCommand.php +++ b/src/Command/Views/DebugCommand.php @@ -34,7 +34,8 @@ class DebugCommand extends Command * DebugCommand constructor. * @param EntityTypeManagerInterface $entityTypeManager */ - public function __construct(EntityTypeManagerInterface $entityTypeManager) { + public function __construct(EntityTypeManagerInterface $entityTypeManager) + { $this->entityTypeManager = $entityTypeManager; parent::__construct(); } diff --git a/src/Command/Views/DisableCommand.php b/src/Command/Views/DisableCommand.php index 6f83f4d4d..7d849aa4d 100644 --- a/src/Command/Views/DisableCommand.php +++ b/src/Command/Views/DisableCommand.php @@ -37,7 +37,7 @@ class DisableCommand extends Command /** * DisableCommand constructor. * @param EntityTypeManagerInterface $entityTypeManager - * @param QueryFactory $entityQuery + * @param QueryFactory $entityQuery */ public function __construct( EntityTypeManagerInterface $entityTypeManager, diff --git a/src/Command/Views/EnableCommand.php b/src/Command/Views/EnableCommand.php index b0133c31b..5c76d096d 100644 --- a/src/Command/Views/EnableCommand.php +++ b/src/Command/Views/EnableCommand.php @@ -38,7 +38,7 @@ class EnableCommand extends Command /** * EnableCommand constructor. * @param EntityTypeManagerInterface $entityTypeManager - * @param QueryFactory $entityQuery + * @param QueryFactory $entityQuery */ public function __construct( EntityTypeManagerInterface $entityTypeManager, diff --git a/src/Command/Yaml/DiffCommand.php b/src/Command/Yaml/DiffCommand.php index 41f043b54..dc21cb4d6 100644 --- a/src/Command/Yaml/DiffCommand.php +++ b/src/Command/Yaml/DiffCommand.php @@ -28,9 +28,10 @@ class DiffCommand extends Command /** * RebuildCommand constructor. - * @param NestedArray $nestedArray + * @param NestedArray $nestedArray */ - public function __construct(NestedArray $nestedArray) { + public function __construct(NestedArray $nestedArray) + { $this->nestedArray = $nestedArray; parent::__construct(); } @@ -127,7 +128,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $statistics = ['total' => 0, 'equal'=> 0 , 'diff' => 0]; -/* print_r($yamlLeftParsed); + /* print_r($yamlLeftParsed); print_r($yamlRightParsed);*/ $diff = $this->nestedArray->arrayDiff($yamlLeftParsed, $yamlRightParsed, $negate, $statistics); print_r($diff); diff --git a/src/Command/Yaml/GetValueCommand.php b/src/Command/Yaml/GetValueCommand.php index 2ecb8b3df..ee5df1f53 100644 --- a/src/Command/Yaml/GetValueCommand.php +++ b/src/Command/Yaml/GetValueCommand.php @@ -27,9 +27,10 @@ class GetValueCommand extends Command /** * RebuildCommand constructor. - * @param NestedArray $nestedArray + * @param NestedArray $nestedArray */ - public function __construct(NestedArray $nestedArray) { + public function __construct(NestedArray $nestedArray) + { $this->nestedArray = $nestedArray; parent::__construct(); } diff --git a/src/Command/Yaml/MergeCommand.php b/src/Command/Yaml/MergeCommand.php index fa5a50ee6..df80b4e7f 100644 --- a/src/Command/Yaml/MergeCommand.php +++ b/src/Command/Yaml/MergeCommand.php @@ -159,10 +159,9 @@ protected function interact(InputInterface $input, OutputInterface $output) while (true) { // Set the string key based on among files provided - if(count($yaml_files) >= 2) { + if (count($yaml_files) >= 2) { $questionStringKey = 'commands.yaml.merge.questions.other-file'; - } - else { + } else { $questionStringKey = 'commands.yaml.merge.questions.file'; } diff --git a/src/Command/Yaml/SplitCommand.php b/src/Command/Yaml/SplitCommand.php index 56392892c..313cfc97f 100644 --- a/src/Command/Yaml/SplitCommand.php +++ b/src/Command/Yaml/SplitCommand.php @@ -29,9 +29,10 @@ class SplitCommand extends Command /** * RebuildCommand constructor. - * @param NestedArray $nestedArray + * @param NestedArray $nestedArray */ - public function __construct(NestedArray $nestedArray) { + public function __construct(NestedArray $nestedArray) + { $this->nestedArray = $nestedArray; parent::__construct(); } diff --git a/src/Command/Yaml/UnsetKeyCommand.php b/src/Command/Yaml/UnsetKeyCommand.php index d744e6bbe..add8e252c 100644 --- a/src/Command/Yaml/UnsetKeyCommand.php +++ b/src/Command/Yaml/UnsetKeyCommand.php @@ -19,90 +19,91 @@ class UnsetKeyCommand extends Command { - use CommandTrait; + use CommandTrait; - /** + /** * @var NestedArray */ - protected $nestedArray; + protected $nestedArray; - /** + /** * RebuildCommand constructor. - * @param NestedArray $nestedArray + * @param NestedArray $nestedArray */ - public function __construct(NestedArray $nestedArray) { - $this->nestedArray = $nestedArray; - parent::__construct(); - } - - protected function configure() - { - $this - ->setName('yaml:unset:key') - ->setDescription($this->trans('commands.yaml.unset.key.description')) - ->addArgument( - 'yaml-file', - InputArgument::REQUIRED, - $this->trans('commands.yaml.unset.value.arguments.yaml-file') - ) - ->addArgument( - 'yaml-key', - InputArgument::REQUIRED, - $this->trans('commands.yaml.unset.value.arguments.yaml-key') - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $yaml = new Parser(); - $dumper = new Dumper(); - - $yaml_file = $input->getArgument('yaml-file'); - $yaml_key = $input->getArgument('yaml-key'); - - try { - $yaml_parsed = $yaml->parse(file_get_contents($yaml_file)); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-parsing').': '.$e->getMessage()); - - return; + public function __construct(NestedArray $nestedArray) + { + $this->nestedArray = $nestedArray; + parent::__construct(); } - if (empty($yaml_parsed)) { - $io->info( - sprintf( - $this->trans('commands.yaml.merge.messages.wrong-parse'), - $yaml_file - ) - ); + protected function configure() + { + $this + ->setName('yaml:unset:key') + ->setDescription($this->trans('commands.yaml.unset.key.description')) + ->addArgument( + 'yaml-file', + InputArgument::REQUIRED, + $this->trans('commands.yaml.unset.value.arguments.yaml-file') + ) + ->addArgument( + 'yaml-key', + InputArgument::REQUIRED, + $this->trans('commands.yaml.unset.value.arguments.yaml-key') + ); } - $parents = explode(".", $yaml_key); - $this->nestedArray->unsetValue($yaml_parsed, $parents); - - try { - $yaml = $dumper->dump($yaml_parsed, 10); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-generating').': '.$e->getMessage()); - - return; - } - - try { - file_put_contents($yaml_file, $yaml); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-writing').': '.$e->getMessage()); - - return; + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new DrupalStyle($input, $output); + + $yaml = new Parser(); + $dumper = new Dumper(); + + $yaml_file = $input->getArgument('yaml-file'); + $yaml_key = $input->getArgument('yaml-key'); + + try { + $yaml_parsed = $yaml->parse(file_get_contents($yaml_file)); + } catch (\Exception $e) { + $io->error($this->trans('commands.yaml.merge.messages.error-parsing').': '.$e->getMessage()); + + return; + } + + if (empty($yaml_parsed)) { + $io->info( + sprintf( + $this->trans('commands.yaml.merge.messages.wrong-parse'), + $yaml_file + ) + ); + } + + $parents = explode(".", $yaml_key); + $this->nestedArray->unsetValue($yaml_parsed, $parents); + + try { + $yaml = $dumper->dump($yaml_parsed, 10); + } catch (\Exception $e) { + $io->error($this->trans('commands.yaml.merge.messages.error-generating').': '.$e->getMessage()); + + return; + } + + try { + file_put_contents($yaml_file, $yaml); + } catch (\Exception $e) { + $io->error($this->trans('commands.yaml.merge.messages.error-writing').': '.$e->getMessage()); + + return; + } + + $io->info( + sprintf( + $this->trans('commands.yaml.unset.value.messages.unset'), + $yaml_file + ) + ); } - - $io->info( - sprintf( - $this->trans('commands.yaml.unset.value.messages.unset'), - $yaml_file - ) - ); - } } diff --git a/src/Command/Yaml/UpdateKeyCommand.php b/src/Command/Yaml/UpdateKeyCommand.php index f194837fe..be9a7d27f 100644 --- a/src/Command/Yaml/UpdateKeyCommand.php +++ b/src/Command/Yaml/UpdateKeyCommand.php @@ -28,9 +28,10 @@ class UpdateKeyCommand extends Command /** * RebuildCommand constructor. - * @param NestedArray $nestedArray + * @param NestedArray $nestedArray */ - public function __construct(NestedArray $nestedArray) { + public function __construct(NestedArray $nestedArray) + { $this->nestedArray = $nestedArray; parent::__construct(); } diff --git a/src/Command/Yaml/UpdateValueCommand.php b/src/Command/Yaml/UpdateValueCommand.php index 76dc11148..a78823143 100644 --- a/src/Command/Yaml/UpdateValueCommand.php +++ b/src/Command/Yaml/UpdateValueCommand.php @@ -28,9 +28,10 @@ class UpdateValueCommand extends Command /** * RebuildCommand constructor. - * @param NestedArray $nestedArray + * @param NestedArray $nestedArray */ - public function __construct(NestedArray $nestedArray) { + public function __construct(NestedArray $nestedArray) + { $this->nestedArray = $nestedArray; parent::__construct(); } diff --git a/src/Extension/Manager.php b/src/Extension/Manager.php index cecafc673..e9113d291 100644 --- a/src/Extension/Manager.php +++ b/src/Extension/Manager.php @@ -284,11 +284,11 @@ private function createExtension($extension) } /** - * @param string $testType + * @param string $testType * @param $fullPath * @return string */ - public function getTestPath( $testType, $fullPath = false) + public function getTestPath($testType, $fullPath = false) { return $this->getPath($fullPath) . '/Tests/' . $testType; } diff --git a/src/Generator/AuthenticationProviderGenerator.php b/src/Generator/AuthenticationProviderGenerator.php index ca7157e1c..bc7b6788b 100644 --- a/src/Generator/AuthenticationProviderGenerator.php +++ b/src/Generator/AuthenticationProviderGenerator.php @@ -11,8 +11,9 @@ class AuthenticationProviderGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/BreakPointGenerator.php b/src/Generator/BreakPointGenerator.php index 693bf4949..e036a54b0 100644 --- a/src/Generator/BreakPointGenerator.php +++ b/src/Generator/BreakPointGenerator.php @@ -15,8 +15,9 @@ */ class BreakPointGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/CommandGenerator.php b/src/Generator/CommandGenerator.php index 4a175665a..b882b1776 100644 --- a/src/Generator/CommandGenerator.php +++ b/src/Generator/CommandGenerator.php @@ -18,7 +18,6 @@ */ class CommandGenerator extends Generator { - /** * @var Manager */ @@ -31,7 +30,7 @@ class CommandGenerator extends Generator /** * CommandGenerator constructor. - * @param Manager $extensionManager + * @param Manager $extensionManager * @param TranslatorManager $translatorManager */ public function __construct( @@ -86,6 +85,5 @@ public function generate($module, $name, $class, $containerAware, $services) 'module/src/Command/console/translations/en/command.yml.twig', $this->extensionManager->getModule($module)->getPath().'/console/translations/en/'.$command_key.'.yml' ); - } } diff --git a/src/Generator/ControllerGenerator.php b/src/Generator/ControllerGenerator.php index 9ebb2c476..21733e8b0 100644 --- a/src/Generator/ControllerGenerator.php +++ b/src/Generator/ControllerGenerator.php @@ -11,8 +11,9 @@ class ControllerGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/EntityBundleGenerator.php b/src/Generator/EntityBundleGenerator.php index 2056fc222..67a671e5e 100644 --- a/src/Generator/EntityBundleGenerator.php +++ b/src/Generator/EntityBundleGenerator.php @@ -11,8 +11,9 @@ class EntityBundleGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/EntityConfigGenerator.php b/src/Generator/EntityConfigGenerator.php index d415d3a6b..e7fec2bb2 100644 --- a/src/Generator/EntityConfigGenerator.php +++ b/src/Generator/EntityConfigGenerator.php @@ -6,13 +6,14 @@ */ namespace Drupal\Console\Generator; + use Drupal\Console\Extension\Manager; class EntityConfigGenerator extends Generator { - - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/EntityContentGenerator.php b/src/Generator/EntityContentGenerator.php index 61bc9de0b..b4a076c6c 100644 --- a/src/Generator/EntityContentGenerator.php +++ b/src/Generator/EntityContentGenerator.php @@ -14,8 +14,9 @@ class EntityContentGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** @@ -23,15 +24,17 @@ class EntityContentGenerator extends Generator */ protected $site; - /** @var TwigRenderer*/ + /** + * @var TwigRenderer +*/ protected $twigrenderer; protected $io; /** * EntityContentGenerator constructor. - * @param Manager $extensionManager - * @param Site $site + * @param Manager $extensionManager + * @param Site $site * @param TwigRenderer $twigrenderer */ public function __construct( @@ -60,7 +63,7 @@ public function setIo($io) * @param string $base_path Base path * @param string $is_translatable Translation configuration * @param string $bundle_entity_type (Config) entity type acting as bundle - * @param bool $revisionable Revision configuration + * @param bool $revisionable Revision configuration */ public function generate($module, $entity_name, $entity_class, $label, $base_path, $is_translatable, $bundle_entity_type = null, $revisionable = false) { @@ -178,36 +181,36 @@ public function generate($module, $entity_name, $entity_class, $label, $base_pat ); if ($revisionable) { - $this->renderFile( - 'module/src/Entity/Form/entity-content-revision-delete.php.twig', - $this->extensionManager->getModule($module)->getFormPath() .'/'.$entity_class.'RevisionDeleteForm.php', - $parameters - ); - $this->renderFile( - 'module/src/Entity/Form/entity-content-revision-revert-translation.php.twig', - $this->extensionManager->getModule($module)->getFormPath() .'/'.$entity_class.'RevisionRevertTranslationForm.php', - $parameters - ); - $this->renderFile( - 'module/src/Entity/Form/entity-content-revision-revert.php.twig', - $this->extensionManager->getModule($module)->getFormPath().'/'.$entity_class.'RevisionRevertForm.php', - $parameters - ); - $this->renderFile( - 'module/src/entity-storage.php.twig', - $this->extensionManager->getModule($module)->getSourcePath() .'/'.$entity_class.'Storage.php', - $parameters - ); - $this->renderFile( - 'module/src/interface-entity-storage.php.twig', - $this->extensionManager->getModule($module)->getSourcePath() .'/'.$entity_class.'StorageInterface.php', - $parameters - ); - $this->renderFile( - 'module/src/Controller/entity-controller.php.twig', - $this->extensionManager->getModule($module)->getControllerPath() .'/'.$entity_class.'Controller.php', - $parameters - ); + $this->renderFile( + 'module/src/Entity/Form/entity-content-revision-delete.php.twig', + $this->extensionManager->getModule($module)->getFormPath() .'/'.$entity_class.'RevisionDeleteForm.php', + $parameters + ); + $this->renderFile( + 'module/src/Entity/Form/entity-content-revision-revert-translation.php.twig', + $this->extensionManager->getModule($module)->getFormPath() .'/'.$entity_class.'RevisionRevertTranslationForm.php', + $parameters + ); + $this->renderFile( + 'module/src/Entity/Form/entity-content-revision-revert.php.twig', + $this->extensionManager->getModule($module)->getFormPath().'/'.$entity_class.'RevisionRevertForm.php', + $parameters + ); + $this->renderFile( + 'module/src/entity-storage.php.twig', + $this->extensionManager->getModule($module)->getSourcePath() .'/'.$entity_class.'Storage.php', + $parameters + ); + $this->renderFile( + 'module/src/interface-entity-storage.php.twig', + $this->extensionManager->getModule($module)->getSourcePath() .'/'.$entity_class.'StorageInterface.php', + $parameters + ); + $this->renderFile( + 'module/src/Controller/entity-controller.php.twig', + $this->extensionManager->getModule($module)->getControllerPath() .'/'.$entity_class.'Controller.php', + $parameters + ); } if ($bundle_entity_type) { diff --git a/src/Generator/EventSubscriberGenerator.php b/src/Generator/EventSubscriberGenerator.php index 5adb9f618..bc7473ca7 100644 --- a/src/Generator/EventSubscriberGenerator.php +++ b/src/Generator/EventSubscriberGenerator.php @@ -11,7 +11,9 @@ class EventSubscriberGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/FormAlterGenerator.php b/src/Generator/FormAlterGenerator.php index 32ff7fd2f..6c8fe59dd 100644 --- a/src/Generator/FormAlterGenerator.php +++ b/src/Generator/FormAlterGenerator.php @@ -11,8 +11,9 @@ class FormAlterGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/FormGenerator.php b/src/Generator/FormGenerator.php index 3d6077f8e..c7b68b7e1 100644 --- a/src/Generator/FormGenerator.php +++ b/src/Generator/FormGenerator.php @@ -12,7 +12,9 @@ class FormGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** @@ -22,7 +24,7 @@ class FormGenerator extends Generator /** * AuthenticationProviderGenerator constructor. - * @param Manager $extensionManager + * @param Manager $extensionManager * @param StringConverter $stringConverter */ public function __construct( diff --git a/src/Generator/HelpGenerator.php b/src/Generator/HelpGenerator.php index 1bf429d27..185d4250b 100644 --- a/src/Generator/HelpGenerator.php +++ b/src/Generator/HelpGenerator.php @@ -11,9 +11,9 @@ class HelpGenerator extends Generator { - - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/ModuleGenerator.php b/src/Generator/ModuleGenerator.php index 705453c9e..90abda5a7 100644 --- a/src/Generator/ModuleGenerator.php +++ b/src/Generator/ModuleGenerator.php @@ -123,44 +123,44 @@ public function generate( } if ($twigtemplate) { $this->renderFile( - 'module/module-twig-template-append.twig', - $dir .'/' . $machineName . '.module', - $parameters, - FILE_APPEND + 'module/module-twig-template-append.twig', + $dir .'/' . $machineName . '.module', + $parameters, + FILE_APPEND ); - $dir .= '/templates/'; - if (file_exists($dir)) { - if (!is_dir($dir)) { - throw new \RuntimeException( - sprintf( - 'Unable to generate the templates directory as the target directory "%s" exists but is a file.', - realpath($dir) - ) - ); - } - $files = scandir($dir); - if ($files != array('.', '..')) { - throw new \RuntimeException( - sprintf( - 'Unable to generate the templates directory as the target directory "%s" is not empty.', - realpath($dir) - ) - ); - } - if (!is_writable($dir)) { - throw new \RuntimeException( - sprintf( - 'Unable to generate the templates directory as the target directory "%s" is not writable.', - realpath($dir) - ) - ); - } - } - $this->renderFile( - 'module/twig-template-file.twig', - $dir . $machineName . '.html.twig', - $parameters - ); - } + $dir .= '/templates/'; + if (file_exists($dir)) { + if (!is_dir($dir)) { + throw new \RuntimeException( + sprintf( + 'Unable to generate the templates directory as the target directory "%s" exists but is a file.', + realpath($dir) + ) + ); + } + $files = scandir($dir); + if ($files != array('.', '..')) { + throw new \RuntimeException( + sprintf( + 'Unable to generate the templates directory as the target directory "%s" is not empty.', + realpath($dir) + ) + ); + } + if (!is_writable($dir)) { + throw new \RuntimeException( + sprintf( + 'Unable to generate the templates directory as the target directory "%s" is not writable.', + realpath($dir) + ) + ); + } + } + $this->renderFile( + 'module/twig-template-file.twig', + $dir . $machineName . '.html.twig', + $parameters + ); + } } } diff --git a/src/Generator/PluginBlockGenerator.php b/src/Generator/PluginBlockGenerator.php index ed92d2e11..03d512c98 100644 --- a/src/Generator/PluginBlockGenerator.php +++ b/src/Generator/PluginBlockGenerator.php @@ -40,37 +40,33 @@ public function generate($module, $class_name, $label, $plugin_id, $services, $i // Consider the type when determining a default value. Figure out what // the code looks like for the default value tht we need to generate. foreach ($inputs as &$input) { - $default_code = '$this->t(\'\')'; - if ($input['default_value'] == '') { - switch ($input['type']) { - case 'checkbox': - case 'number': - case 'weight': - case 'radio': - $default_code = 0; - break; + $default_code = '$this->t(\'\')'; + if ($input['default_value'] == '') { + switch ($input['type']) { + case 'checkbox': + case 'number': + case 'weight': + case 'radio': + $default_code = 0; + break; - case 'radios': - case 'checkboxes': - $default_code = 'array()'; - break; + case 'radios': + case 'checkboxes': + $default_code = 'array()'; + break; + } + } elseif (substr($input['default_value'], 0, 1) == '$') { + // If they want to put in code, let them, they're programmers. + $default_code = $input['default_value']; + } elseif (is_numeric($input['default_value'])) { + $default_code = $input['default_value']; + } elseif (preg_match('/^(true|false)$/i', $input['default_value'])) { + // Coding Standards + $default_code = strtoupper($input['default_value']); + } else { + $default_code = '$this->t(\'' . $input['default_value'] . '\')'; } - } - elseif (substr($input['default_value'], 0, 1) == '$') { - // If they want to put in code, let them, they're programmers. - $default_code = $input['default_value']; - } - elseif (is_numeric($input['default_value'])) { - $default_code = $input['default_value']; - } - elseif (preg_match('/^(true|false)$/i', $input['default_value'])) { - // Coding Standards - $default_code = strtoupper($input['default_value']); - } - else { - $default_code = '$this->t(\'' . $input['default_value'] . '\')'; - } - $input['default_code'] = $default_code; + $input['default_code'] = $default_code; } $parameters = [ diff --git a/src/Generator/PluginCKEditorButtonGenerator.php b/src/Generator/PluginCKEditorButtonGenerator.php index ab2b2604e..d809e7b9d 100644 --- a/src/Generator/PluginCKEditorButtonGenerator.php +++ b/src/Generator/PluginCKEditorButtonGenerator.php @@ -11,9 +11,9 @@ class PluginCKEditorButtonGenerator extends Generator { - - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; diff --git a/src/Generator/PluginConditionGenerator.php b/src/Generator/PluginConditionGenerator.php index 858b3d802..60fe6cf01 100644 --- a/src/Generator/PluginConditionGenerator.php +++ b/src/Generator/PluginConditionGenerator.php @@ -15,8 +15,9 @@ */ class PluginConditionGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; diff --git a/src/Generator/PluginRulesActionGenerator.php b/src/Generator/PluginRulesActionGenerator.php index 10455c2e3..1b27f3860 100644 --- a/src/Generator/PluginRulesActionGenerator.php +++ b/src/Generator/PluginRulesActionGenerator.php @@ -11,7 +11,6 @@ class PluginRulesActionGenerator extends Generator { - /** * PluginRulesActionGenerator constructor. * @param Manager $extensionManager diff --git a/src/Generator/PluginViewsFieldGenerator.php b/src/Generator/PluginViewsFieldGenerator.php index 924cb1513..3e8c7cbc2 100644 --- a/src/Generator/PluginViewsFieldGenerator.php +++ b/src/Generator/PluginViewsFieldGenerator.php @@ -11,7 +11,9 @@ class PluginViewsFieldGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/PostUpdateGenerator.php b/src/Generator/PostUpdateGenerator.php index 0f3c31acd..e9205514f 100644 --- a/src/Generator/PostUpdateGenerator.php +++ b/src/Generator/PostUpdateGenerator.php @@ -11,7 +11,9 @@ class PostUpdateGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/RouteSubscriberGenerator.php b/src/Generator/RouteSubscriberGenerator.php index d7ced3cd7..9e451439a 100644 --- a/src/Generator/RouteSubscriberGenerator.php +++ b/src/Generator/RouteSubscriberGenerator.php @@ -11,7 +11,9 @@ class RouteSubscriberGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/ServiceGenerator.php b/src/Generator/ServiceGenerator.php index bad04e973..2ab2fe4be 100644 --- a/src/Generator/ServiceGenerator.php +++ b/src/Generator/ServiceGenerator.php @@ -11,7 +11,9 @@ class ServiceGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/ThemeGenerator.php b/src/Generator/ThemeGenerator.php index 8b1633b6a..6b686a336 100644 --- a/src/Generator/ThemeGenerator.php +++ b/src/Generator/ThemeGenerator.php @@ -14,8 +14,9 @@ */ class ThemeGenerator extends Generator { - - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/TwigExtensionGenerator.php b/src/Generator/TwigExtensionGenerator.php index de5b95400..76c474a2f 100644 --- a/src/Generator/TwigExtensionGenerator.php +++ b/src/Generator/TwigExtensionGenerator.php @@ -15,7 +15,9 @@ */ class TwigExtensionGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Generator/UpdateGenerator.php b/src/Generator/UpdateGenerator.php index 23de36b1a..fe8243f6d 100644 --- a/src/Generator/UpdateGenerator.php +++ b/src/Generator/UpdateGenerator.php @@ -11,7 +11,9 @@ class UpdateGenerator extends Generator { - /** @var Manager */ + /** + * @var Manager +*/ protected $extensionManager; /** diff --git a/src/Utils/AnnotationValidator.php b/src/Utils/AnnotationValidator.php index 4154fc148..43afe07bb 100644 --- a/src/Utils/AnnotationValidator.php +++ b/src/Utils/AnnotationValidator.php @@ -9,8 +9,8 @@ * Class AnnotationValidator * @package Drupal\Console\Utils */ -class AnnotationValidator { - +class AnnotationValidator +{ /** * @var DrupalCommandAnnotationReader */ @@ -41,7 +41,8 @@ public function __construct( * @param $class * @return bool */ - public function isValidCommand($class) { + public function isValidCommand($class) + { $annotation = $this->annotationCommandReader->readAnnotation($class); if (!$annotation) { return true; @@ -66,25 +67,26 @@ public function isValidCommand($class) { * @param $extension * @return bool */ - protected function isExtensionInstalled($extension){ + protected function isExtensionInstalled($extension) + { if (!$this->extensions) { - $modules = $this->extensionManager->discoverModules() + $modules = $this->extensionManager->discoverModules() ->showCore() ->showNoCore() ->showInstalled() - ->getList(TRUE); + ->getList(true); $themes = $this->extensionManager->discoverThemes() ->showCore() ->showNoCore() ->showInstalled() - ->getList(TRUE); + ->getList(true); $profiles = $this->extensionManager->discoverProfiles() ->showCore() ->showNoCore() ->showInstalled() - ->getList(TRUE); + ->getList(true); $this->extensions = array_merge( $modules, @@ -100,7 +102,8 @@ protected function isExtensionInstalled($extension){ * @param $annotation * @return array */ - protected function extractDependencies($annotation) { + protected function extractDependencies($annotation) + { $dependencies = []; if (array_key_exists('extension', $annotation)) { $dependencies[] = $annotation['extension']; @@ -111,4 +114,4 @@ protected function extractDependencies($annotation) { return $dependencies; } -} \ No newline at end of file +} diff --git a/src/Utils/DrupalApi.php b/src/Utils/DrupalApi.php index b0e660a33..06d580fef 100644 --- a/src/Utils/DrupalApi.php +++ b/src/Utils/DrupalApi.php @@ -314,14 +314,15 @@ private function getComposerReleases($url, $limit = 10, $unstable = false) * * Rebuilds all caches even when Drupal itself does not work. * - * @param \Composer\Autoload\ClassLoader $class_loader + * @param \Composer\Autoload\ClassLoader $class_loader * The class loader. * @param \Symfony\Component\HttpFoundation\Request $request * The current request. * * @see rebuild.php */ - public function drupal_rebuild($class_loader, \Symfony\Component\HttpFoundation\Request $request) { + public function drupal_rebuild($class_loader, \Symfony\Component\HttpFoundation\Request $request) + { // Remove Drupal's error and exception handlers; they rely on a working // service container and other subsystems and will only cause a fatal error // that hides the actual error. diff --git a/src/Utils/Site.php b/src/Utils/Site.php index c561f4cb7..aafe8cbfa 100644 --- a/src/Utils/Site.php +++ b/src/Utils/Site.php @@ -141,7 +141,7 @@ public function getAutoload() */ public function multisiteMode($uri) { - if($uri != 'default') { + if ($uri != 'default') { return true; } @@ -164,7 +164,7 @@ public function validMultisite($uri) return false; } - if(isset($sites[$uri]) && is_dir($this->appRoot . "/sites/" . $sites[$uri])) { + if (isset($sites[$uri]) && is_dir($this->appRoot . "/sites/" . $sites[$uri])) { return true; }