Commit 76a4b4c8 authored by Damien McKenna's avatar Damien McKenna
Browse files

Issue #2841737 by DamienMcKenna, andyg5000, harold20, jmolivas, jim22:...

Issue #2841737 by DamienMcKenna, andyg5000, harold20, jmolivas, jim22: DrupalConsole commands not working.
parent d78921c9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@ Metatag 8.x-1.x-dev, xxxx-xx-xx
#3106609 by bygeoffthompson, Daniel Korte, DamienMcKenna, Maya Slatinek,
  mrshowerman, BryanDeNijs: The Basic Description field has a maxlength of 255
  but recommends 320 or less.
#2841737 by DamienMcKenna, andyg5000, harold20, jmolivas, jim22: DrupalConsole
  commands not working.


Metatag 8.x-1.11, 2019-12-20
+2 −2
Original line number Diff line number Diff line
services:
  metatag.generate_tag:
    class: Drupal\metatag\Command\GenerateTagCommand
    arguments: ['@metatag.manager', '@metatag.tag_generator', '@?console.extension_manager', '@?console.string_converter', '@?console.chain_queue']
    arguments: ['@metatag.manager', '@metatag.tag_generator', '@?console.extension_manager', '@?console.string_converter', '@?console.chain_queue', '@console.validator']
    tags:
      - { name: drupal.command }

  metatag.generate_group:
    class: Drupal\metatag\Command\GenerateGroupCommand
    arguments: ['@metatag.group_generator', '@?console.extension_manager', '@?console.chain_queue']
    arguments: ['@metatag.group_generator', '@?console.extension_manager', '@?console.chain_queue', '@console.validator']
    tags:
      - { name: drupal.command }

+70 −44
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ namespace Drupal\metatag\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Command\Command;
use Drupal\Console\Core\Command\Shared\CommandTrait;
use Drupal\Console\Command\Shared\ModuleTrait;
use Drupal\Console\Command\Shared\FormTrait;
@@ -14,6 +13,8 @@ use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\metatag\Generator\MetatagGroupGenerator;
use Drupal\Console\Extension\Manager;
use Drupal\Console\Core\Utils\ChainQueue;
use Drupal\Console\Core\Command\Command;
use Drupal\Console\Utils\Validator;

/**
 * Class GenerateGroupCommand.
@@ -24,9 +25,7 @@ use Drupal\Console\Core\Utils\ChainQueue;
 */
class GenerateGroupCommand extends Command {

  use CommandTrait;
  use ModuleTrait;
  use FormTrait;
  use ConfirmationTrait;

  /**
@@ -50,6 +49,11 @@ class GenerateGroupCommand extends Command {
   */
  protected $chainQueue;

  /**
   * @var Validator
   */
  protected $validator;

  /**
   * The GenerateTagCommand constructor.
   *
@@ -59,15 +63,18 @@ class GenerateGroupCommand extends Command {
   *   The extension manager object.
   * @param \Drupal\Console\Core\Utils\ChainQueue $chainQueue
   *   The chain queue object.
   * @param Validator $validator
   */
  public function __construct(
      MetatagGroupGenerator $generator,
      Manager $extensionManager,
      ChainQueue $chainQueue
      ChainQueue $chainQueue,
      Validator $validator
    ) {
    $this->generator = $generator;
    $this->extensionManager = $extensionManager;
    $this->chainQueue = $chainQueue;
    $this->validator = $validator;

    parent::__construct();
  }
@@ -80,39 +87,61 @@ class GenerateGroupCommand extends Command {
      ->setName('generate:plugin:metatag:group')
      ->setDescription($this->trans('commands.generate.metatag.group.description'))
      ->setHelp($this->trans('commands.generate.metatag.group.help'))
      ->addOption('base_class', '', InputOption::VALUE_REQUIRED,
        $this->trans('commands.common.options.base_class'))
      ->addOption('module', '', InputOption::VALUE_REQUIRED,
        $this->trans('commands.common.options.module'))
      ->addOption('label', '', InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.group.options.label'))
      ->addOption('description', '', InputOption::VALUE_OPTIONAL,
        $this->trans('commands.generate.metatag.group.options.description'))
      ->addOption('plugin-id', '', InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.group.options.plugin_id'))
      ->addOption('class-name', '', InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.group.options.class_name'))
      ->addOption('weight', '', InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.group.options.weight'));
      ->addOption(
        'base_class',
        null,
        InputOption::VALUE_REQUIRED,
        $this->trans('commands.common.options.base_class')
      )
      ->addOption(
        'module',
        null,
        InputOption::VALUE_REQUIRED,
        $this->trans('commands.common.options.module')
      )
      ->addOption(
        'label',
        null,
        InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.group.options.label')
      )
      ->addOption(
        'description',
        null,
        InputOption::VALUE_OPTIONAL,
        $this->trans('commands.generate.metatag.group.options.description')
      )
      ->addOption(
        'plugin-id',
        null,
        InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.group.options.plugin_id')
      )
      ->addOption(
        'class-name',
        null,
        InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.group.options.class_name')
      )
      ->addOption(
        'weight',
        null,
        InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.group.options.weight')
      );
  }

  /**
   * {@inheritdoc}
   */
  protected function execute(InputInterface $input, OutputInterface $output) {
    $io = new DrupalStyle($input, $output);

    // @see Drupal\Console\Command\ConfirmationTrait::confirmGeneration
    if (!$this->confirmGeneration($io)) {
      return 1;
    }

    $module = $this->validateModule($input->getOption('module'));
    $base_class = $input->getOption('base_class');
    $module = $input->getOption('module');
    $label = $input->getOption('label');
    $description = $input->getOption('description');
    $plugin_id = $input->getOption('plugin-id');
    $class_name = $input->getOption('class-name');
    $class_name = $this->validator->validateClassName($input->getOption('class-name'));
    $weight = $input->getOption('weight');

    $this->generator
@@ -125,31 +154,24 @@ class GenerateGroupCommand extends Command {
   * {@inheritdoc}
   */
  protected function interact(InputInterface $input, OutputInterface $output) {
    $io = new DrupalStyle($input, $output);

    // --base_class option.
    // @todo Turn this into a choice() option.
    $base_class = $input->getOption('base_class');
    if (empty($base_class)) {
      $base_class = $io->ask(
      $base_class = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.group.questions.base_class'),
        'GroupBase'
      );
    }
    $input->setOption('base_class', $base_class);

    // --module option.
    $module = $input->getOption('module');
    if (empty($module)) {
      // @see Drupal\AppConsole\Command\Helper\ModuleTrait::moduleQuestion
      $module = $this->moduleQuestion($io);
    }
    $input->setOption('module', $module);
    // --module option
    $this->getModuleOption();

    // --label option.
    $label = $input->getOption('label');
    if (empty($label)) {
      $label = $io->ask(
      $label = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.group.questions.label')
      );
    }
@@ -158,7 +180,7 @@ class GenerateGroupCommand extends Command {
    // --description option.
    $description = $input->getOption('description');
    if (empty($description)) {
      $description = $io->ask(
      $description = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.group.questions.description')
      );
    }
@@ -167,7 +189,7 @@ class GenerateGroupCommand extends Command {
    // --plugin-id option.
    $plugin_id = $input->getOption('plugin-id');
    if (empty($plugin_id)) {
      $plugin_id = $io->ask(
      $plugin_id = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.group.questions.plugin_id')
      );
    }
@@ -175,18 +197,22 @@ class GenerateGroupCommand extends Command {

    // --class-name option.
    $class_name = $input->getOption('class-name');
    if (empty($class_name)) {
      $class_name = $io->ask(
        $this->trans('commands.generate.metatag.group.questions.class_name')
      );
    if (!$class_name) {
      $class_name = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.group.questions.class_name'),
        '',
        function ($class_name) {
          return $this->validator->validateClassName($class_name);
        }
      );
      $input->setOption('class-name', $class_name);
    }

    // --weight option.
    // @todo Automatically get the next int value based upon the current group.
    $weight = $input->getOption('weight');
    if (is_null($weight)) {
      $weight = $io->ask(
      $weight = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.group.questions.weight'),
        0
      );
+45 −48
Original line number Diff line number Diff line
@@ -12,10 +12,11 @@ use Drupal\Console\Core\Utils\StringConverter;
use Drupal\Console\Extension\Manager;
use Drupal\metatag\Generator\MetatagTagGenerator;
use Drupal\metatag\MetatagManagerInterface;
use Symfony\Component\Console\Command\Command;
use Drupal\Console\Core\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Drupal\Console\Utils\Validator;

/**
 * Class GenerateTagCommand.
@@ -26,7 +27,6 @@ use Symfony\Component\Console\Output\OutputInterface;
 */
class GenerateTagCommand extends Command {

  use CommandTrait;
  use ModuleTrait;
  use FormTrait;
  use ConfirmationTrait;
@@ -66,6 +66,11 @@ class GenerateTagCommand extends Command {
   */
  protected $chainQueue;

  /**
   * @var Validator
   */
  protected $validator;

  /**
   * The GenerateTagCommand constructor.
   *
@@ -79,19 +84,22 @@ class GenerateTagCommand extends Command {
   *   The string converter object.
   * @param \Drupal\Console\Core\Utils\ChainQueue $chainQueue
   *   The chain queue object.
   * @param Validator $validator
   */
  public function __construct(
      MetatagManagerInterface $metatagManager,
      MetatagTagGenerator $generator,
      Manager $extensionManager,
      StringConverter $stringConverter,
      ChainQueue $chainQueue
      ChainQueue $chainQueue,
      Validator $validator
  ) {
    $this->metatagManager = $metatagManager;
    $this->generator = $generator;
    $this->extensionManager = $extensionManager;
    $this->stringConverter = $stringConverter;
    $this->chainQueue = $chainQueue;
    $this->validator = $validator;

    parent::__construct();
  }
@@ -104,29 +112,29 @@ class GenerateTagCommand extends Command {
      ->setName('generate:plugin:metatag:tag')
      ->setDescription($this->trans('commands.generate.metatag.tag.description'))
      ->setHelp($this->trans('commands.generate.metatag.tag.help'))
      ->addOption('base_class', '', InputOption::VALUE_REQUIRED,
      ->addOption('base_class', null, InputOption::VALUE_REQUIRED,
        $this->trans('commands.common.options.base_class'))
      ->addOption('module', '', InputOption::VALUE_REQUIRED,
      ->addOption('module', null, InputOption::VALUE_REQUIRED,
        $this->trans('commands.common.options.module'))
      ->addOption('name', '', InputOption::VALUE_REQUIRED,
      ->addOption('name', null, InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.tag.options.name'))
      ->addOption('label', '', InputOption::VALUE_REQUIRED,
      ->addOption('label', null, InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.tag.options.label'))
      ->addOption('description', '', InputOption::VALUE_OPTIONAL,
      ->addOption('description', null, InputOption::VALUE_OPTIONAL,
        $this->trans('commands.generate.metatag.tag.options.description'))
      ->addOption('plugin-id', '', InputOption::VALUE_REQUIRED,
      ->addOption('plugin-id', null, InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.tag.options.plugin_id'))
      ->addOption('class-name', '', InputOption::VALUE_REQUIRED,
      ->addOption('class-name', null, InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.tag.options.class_name'))
      ->addOption('group', '', InputOption::VALUE_REQUIRED,
      ->addOption('group', null, InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.tag.options.group'))
      ->addOption('weight', '', InputOption::VALUE_REQUIRED,
      ->addOption('weight', null, InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.tag.options.weight'))
      ->addOption('type', '', InputOption::VALUE_REQUIRED,
      ->addOption('type', null, InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.tag.options.type'))
      ->addOption('secure', '', InputOption::VALUE_REQUIRED,
      ->addOption('secure', null, InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.tag.options.secure'))
      ->addOption('multiple', '', InputOption::VALUE_REQUIRED,
      ->addOption('multiple', null, InputOption::VALUE_REQUIRED,
        $this->trans('commands.generate.metatag.tag.options.multiple'));
  }

@@ -134,20 +142,13 @@ class GenerateTagCommand extends Command {
   * {@inheritdoc}
   */
  protected function execute(InputInterface $input, OutputInterface $output) {
    $io = new DrupalStyle($input, $output);

    // @see Drupal\Console\Command\ConfirmationTrait::confirmGeneration
    if (!$this->confirmGeneration($io)) {
      return 1;
    }

    $base_class = $input->getOption('base_class');
    $module = $input->getOption('module');
    $module = $this->validateModule($input->getOption('module'));
    $name = $input->getOption('name');
    $label = $input->getOption('label');
    $description = $input->getOption('description');
    $plugin_id = $input->getOption('plugin-id');
    $class_name = $input->getOption('class-name');
    $class_name = $this->validator->validateClassName($input->getOption('class-name'));
    $group = $input->getOption('group');
    $weight = $input->getOption('weight');
    $type = $input->getOption('type');
@@ -165,8 +166,6 @@ class GenerateTagCommand extends Command {
   */
  protected function interact(InputInterface $input, OutputInterface $output) {

    $io = new DrupalStyle($input, $output);

    $boolean_options = [
      'FALSE',
      'TRUE',
@@ -185,7 +184,7 @@ class GenerateTagCommand extends Command {
    // @todo Turn this into a choice() option.
    $base_class = $input->getOption('base_class');
    if (empty($base_class)) {
      $base_class = $io->ask(
      $base_class = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.tag.questions.base_class'),
        'MetaNameBase'
      );
@@ -193,18 +192,13 @@ class GenerateTagCommand extends Command {
    $input->setOption('base_class', $base_class);

    // --module option.
    $module = $input->getOption('module');
    if (empty($module)) {
      // @see Drupal\AppConsole\Command\Helper\ModuleTrait::moduleQuestion
      $module = $this->moduleQuestion($io);
    }
    $input->setOption('module', $module);
    $this->getModuleOption();

    // --name option.
    // @todo Add validation.
    $name = $input->getOption('name');
    if (empty($name)) {
      $name = $io->ask(
      $name = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.tag.questions.name')
      );
    }
@@ -213,7 +207,7 @@ class GenerateTagCommand extends Command {
    // --label option.
    $label = $input->getOption('label');
    if (empty($label)) {
      $label = $io->ask(
      $label = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.tag.questions.label'),
        $name
      );
@@ -223,7 +217,7 @@ class GenerateTagCommand extends Command {
    // --description option.
    $description = $input->getOption('description');
    if (empty($description)) {
      $description = $io->ask(
      $description = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.tag.questions.description')
      );
    }
@@ -233,7 +227,7 @@ class GenerateTagCommand extends Command {
    $plugin_id = $input->getOption('plugin-id');
    if (empty($plugin_id)) {
      $plugin_id = $this->nameToPluginId($name);
      $plugin_id = $io->ask(
      $plugin_id = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.tag.questions.plugin_id'),
        $plugin_id
      );
@@ -242,20 +236,23 @@ class GenerateTagCommand extends Command {

    // --class-name option.
    $class_name = $input->getOption('class-name');
    if (empty($class_name)) {
      $class_name = $this->nameToClassName($name);
      $class_name = $io->ask(
    if (!$class_name) {
      $class_name = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.tag.questions.class_name'),
        $class_name
      );
        $this->nameToClassName($name),
        function ($class_name) {
          return $this->validator->validateClassName($class_name);
        }
      );
      $input->setOption('class-name', $class_name);
    }


    // --group option.
    $group = $input->getOption('group');
    if (empty($group)) {
      $groups = $this->getGroups();
      $group = $io->choice(
      $group = $this->getIo()->choice(
        $this->trans('commands.generate.metatag.tag.questions.group'),
        $groups
      );
@@ -266,7 +263,7 @@ class GenerateTagCommand extends Command {
    // @todo Automatically get the next int value based upon the current group.
    $weight = $input->getOption('weight');
    if (is_null($weight)) {
      $weight = $io->ask(
      $weight = $this->getIo()->ask(
        $this->trans('commands.generate.metatag.tag.questions.weight'),
        0
      );
@@ -277,7 +274,7 @@ class GenerateTagCommand extends Command {
    // @todo Turn this into an option.
    $type = $input->getOption('type');
    if (is_null($type)) {
      $type = $io->choice(
      $type = $this->getIo()->choice(
        $this->trans('commands.generate.metatag.tag.questions.type'),
        $type_options,
        0
@@ -289,7 +286,7 @@ class GenerateTagCommand extends Command {
    // @todo Turn this into an option.
    $secure = $input->getOption('secure');
    if (is_null($secure)) {
      $secure = $io->choice(
      $secure = $this->getIo()->choice(
        $this->trans('commands.generate.metatag.tag.questions.secure'),
        $boolean_options,
        0
@@ -300,7 +297,7 @@ class GenerateTagCommand extends Command {
    // --multiple option.
    $multiple = $input->getOption('multiple');
    if (is_null($multiple)) {
      $multiple = $io->choice(
      $multiple = $this->getIo()->choice(
        $this->trans('commands.generate.metatag.tag.questions.multiple'),
        $boolean_options,
        0