Chris@0: getReplaceCommandHooks()); Chris@0: } Chris@0: Chris@0: /** Chris@0: * @return \callable[] Chris@0: */ Chris@0: public function getReplaceCommandHooks() Chris@0: { Chris@0: $hooks = [ Chris@0: HookManager::REPLACE_COMMAND_HOOK, Chris@0: ]; Chris@0: $replaceCommandHooks = $this->getHooks($hooks); Chris@0: Chris@0: return $replaceCommandHooks; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @param \Consolidation\AnnotatedCommand\CommandData $commandData Chris@0: * Chris@0: * @return callable Chris@0: */ Chris@0: public function getReplacementCommand(CommandData $commandData) Chris@0: { Chris@0: $replaceCommandHooks = $this->getReplaceCommandHooks(); Chris@0: Chris@0: // We only take the first hook implementation of "replace-command" as the replacement. Commands shouldn't have Chris@0: // more than one replacement. Chris@0: $replacementCommand = reset($replaceCommandHooks); Chris@0: Chris@0: if ($this->logger && count($replaceCommandHooks) > 1) { Chris@0: $command_name = $commandData->annotationData()->get('command', 'unknown'); Chris@0: $message = "Multiple implementations of the \"replace - command\" hook exist for the \"$command_name\" command.\n"; Chris@0: foreach ($replaceCommandHooks as $replaceCommandHook) { Chris@0: $class = get_class($replaceCommandHook[0]); Chris@0: $method = $replaceCommandHook[1]; Chris@0: $hook_name = "$class->$method"; Chris@0: $message .= " - $hook_name\n"; Chris@0: } Chris@0: $this->logger->warning($message); Chris@0: } Chris@0: Chris@0: return $replacementCommand; Chris@0: } Chris@0: }