getName()) { if ('UNKNOWN' !== $this->getVersion()) { $output .= sprintf('%s version %s', $this->getName(), $this->getVersion()); } else { $output .= sprintf('%s', $this->getName()); } } else { $output .= 'Drupal Console'; } return $output; } /** * {@inheritdoc} */ public function doRun(InputInterface $input, OutputInterface $output) { $this->validateCommands(); return parent::doRun($input, $output); } public function validateCommands() { $consoleCommands = $this->container ->findTaggedServiceIds('drupal.command'); if (!$consoleCommands) { return; } $serviceDefinitions = $this->container->getDefinitions(); if (!$serviceDefinitions) { return; } if (!$this->container->has('console.annotation_command_reader')) { return; } /** * @var DrupalCommandAnnotationReader $annotationCommandReader */ $annotationCommandReader = $this->container ->get('console.annotation_command_reader'); if (!$this->container->has('console.annotation_validator')) { return; } /** * @var AnnotationValidator $annotationValidator */ $annotationValidator = $this->container ->get('console.annotation_validator'); $invalidCommands = []; foreach ($consoleCommands as $name => $tags) { AnnotationRegistry::reset(); AnnotationRegistry::registerLoader( [ $this->container->get('class_loader'), "loadClass" ] ); if (!$this->container->has($name)) { $invalidCommands[] = $name; continue; } if (!$serviceDefinition = $serviceDefinitions[$name]) { $invalidCommands[] = $name; continue; } if (!$annotationValidator->isValidCommand( $serviceDefinition->getClass() ) ) { $invalidCommands[] = $name; continue; } $annotation = $annotationCommandReader ->readAnnotation($serviceDefinition->getClass()); if ($annotation) { $this->container->get('console.translator_manager') ->addResourceTranslationsByExtension( $annotation['extension'], $annotation['extensionType'] ); } } $this->container ->get('console.key_value_storage') ->set('invalid_commands', $invalidCommands); return; } }