|
|
@@ -138,17 +138,12 @@ class CommandRunner implements EventDispatcherInterface
|
|
|
'help' => HelpCommand::class,
|
|
|
]);
|
|
|
$commands = $this->app->console($commands);
|
|
|
+ $this->checkCollection($commands, 'console');
|
|
|
+
|
|
|
if ($this->app instanceof PluginApplicationInterface) {
|
|
|
$commands = $this->app->pluginConsole($commands);
|
|
|
}
|
|
|
-
|
|
|
- if (!($commands instanceof CommandCollection)) {
|
|
|
- $type = getTypeName($commands);
|
|
|
- throw new RuntimeException(
|
|
|
- "The application's `console` method did not return a CommandCollection." .
|
|
|
- " Got '{$type}' instead."
|
|
|
- );
|
|
|
- }
|
|
|
+ $this->checkCollection($commands, 'pluginConsole');
|
|
|
$this->dispatchEvent('Console.buildCommands', ['commands' => $commands]);
|
|
|
|
|
|
if (empty($argv)) {
|
|
|
@@ -197,6 +192,26 @@ class CommandRunner implements EventDispatcherInterface
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Check the created CommandCollection
|
|
|
+ *
|
|
|
+ * @param mixed $commands The CommandCollection to check, could be anything though.
|
|
|
+ * @param string $method The method that was used.
|
|
|
+ * @return void
|
|
|
+ * @throws \RuntimeException
|
|
|
+ * @deprecated 3.6.0 This method should be replaced with return types in 4.x
|
|
|
+ */
|
|
|
+ protected function checkCollection($commands, $method)
|
|
|
+ {
|
|
|
+ if (!($commands instanceof CommandCollection)) {
|
|
|
+ $type = getTypeName($commands);
|
|
|
+ throw new RuntimeException(
|
|
|
+ "The application's `{$method}` method did not return a CommandCollection." .
|
|
|
+ " Got '{$type}' instead."
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* Get the application's event manager or the global one.
|
|
|
*
|
|
|
* @return \Cake\Event\EventManagerInterface
|