diff --git a/services.yml b/services.yml index 9dc27f0..27bc47f 100644 --- a/services.yml +++ b/services.yml @@ -23,7 +23,7 @@ services: class: Drupal\Console\Core\Utils\ShellProcess arguments: ['@app.root', '@console.translator_manager'] console.string_converter: - class: Drupal\Console\Core\Utils\StringConverter + class: Drupal\Console\Core\Utils\StringConverter console.chain_discovery: class: Drupal\Console\Core\Utils\ChainDiscovery arguments: ['@console.root', '@console.configuration_manager', '@console.message_manager', '@console.translator_manager'] @@ -33,6 +33,8 @@ services: class: Drupal\Console\Core\Utils\MessageManager console.drupal_finder: class: Drupal\Console\Core\Utils\DrupalFinder + console.key_value_storage: + class: Drupal\Console\Core\Utils\KeyValueStorage # DrupalConsoleCore Commands console.about: class: Drupal\Console\Core\Command\AboutCommand diff --git a/src/Application.php b/src/Application.php index 43a2e13..0486bd4 100644 --- a/src/Application.php +++ b/src/Application.php @@ -61,7 +61,7 @@ class Application extends BaseApplication * @param string $version */ public function __construct( - ContainerInterface$container, + ContainerInterface $container, $name, $version ) { @@ -419,9 +419,8 @@ private function registerCommands() ->get('application.commands.aliases')?:[]; $invalidCommands = []; - if ($this->container->has('console.invalid_commands')) { - $invalidCommands = (array)$this->container - ->get('console.invalid_commands'); + if ($this->container->has('console.key_value_storage')) { + $invalidCommands = $this->container->get('console.key_value_storage')->get('invalid_commands'); } foreach ($consoleCommands as $name => $tags) { diff --git a/src/Utils/KeyValueStorage.php b/src/Utils/KeyValueStorage.php new file mode 100644 index 0000000..d8ef7a3 --- /dev/null +++ b/src/Utils/KeyValueStorage.php @@ -0,0 +1,69 @@ +data); + } + + /** + * Gets the given key from the container, or returns the default if it does + * not exist. + * + * @param string $key + * The key to get. + * @param mixed $default + * Default value to return. + * + * @return mixed + */ + public function get($key, $default = null) + { + return $this->has($key) ? $this->data[$key] : $default; + } + + /** + * Sets the given key in the container. + * + * @param mixed $key + * The key to set + * @param mixed $value + * The value. + */ + public function set($key, $value = null) + { + $this->data[$key] = $value; + } + + /** + * Removes the given key from the container. + * + * @param string $key The key to forget. + * + * @return void + */ + public function remove($key) + { + unset($this->data[$key]); + } + +}