devel_wizard-2.x-dev/src/Commands/BlockContentTypeSpellCommands.php

src/Commands/BlockContentTypeSpellCommands.php
<?php

declare(strict_types=1);

namespace Drupal\devel_wizard\Commands;

use Drush\Attributes as CLI;
use Drush\Boot\DrupalBootLevels;

class BlockContentTypeSpellCommands extends SpellCommandsBase {

  /**
   * @noinspection PhpUnusedParameterInspection
   */
  #[CLI\Command(name: 'devel-wizard:spell:devel_wizard_block_content_type_admin_view')]
  #[CLI\Help(
    description: 'Creates a view for administrators for an existing Block Type.',
  )]
  #[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
  #[CLI\Argument(
    name: 'blockTypeId',
    description: 'The machine-name of the Block Type.',
  )]
  public function cmdAdminViewExecute(string $blockTypeId): void {
    $this->execute();
  }

  /**
   * @noinspection PhpUnusedParameterInspection
   */
  #[CLI\Command(name: 'devel-wizard:spell:devel_wizard_block_content_type_behat')]
  #[CLI\Help(
    description: 'Generates Behat tests for an existing Block Type.',
  )]
  #[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
  #[CLI\Argument(
    name: 'blockTypeId',
    description: 'The machine-name of the Block Type.',
  )]
  public function cmdBehatExecute(string $blockTypeId): void {
    $this->execute();
  }

  /**
   * @noinspection PhpUnusedParameterInspection
   */
  // use Drush\Attributes as CLI;
  #[CLI\Command(name: 'devel-wizard:spell:devel_wizard_block_content_type_create')]
  #[CLI\Help(
    description: 'Creates a new Block Type without any extra.',
  )]
  #[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
  #[CLI\Argument(
    name: 'blockTypeId',
    description: 'The machine-name of the new Block Type.',
  )]
  public function cmdCreateExecute(string $blockTypeId): void {
    $this->execute();
  }

  /**
   * @noinspection PhpUnusedParameterInspection
   */
  #[CLI\Command(name: 'devel-wizard:spell:devel_wizard_block_content_type_migration')]
  #[CLI\Help(
    description: 'Creates migration definitions and data sources for an existing Block Type.',
  )]
  #[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
  #[CLI\Argument(
    name: 'blockTypeId',
    description: 'The machine-name of the new Block Type.',
  )]
  public function cmdMigrationExecute(string $blockTypeId): void {
    $this->execute();
  }

  /**
   * @noinspection PhpUnusedParameterInspection
   */
  #[CLI\Command(name: 'devel-wizard:spell:devel_wizard_block_content_type_user_role')]
  #[CLI\Help(
    description: 'Creates a new user role which grants full control over a specific Block Type.',
    synopsis: '',
  )]
  #[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
  #[CLI\Argument(
    name: 'blockTypeId',
    description: 'The machine-name of the new Block Type.',
  )]
  public function cmdUserRoleExecute(string $blockTypeId): void {
    $this->execute();
  }

  /**
   * @noinspection PhpUnusedParameterInspection
   */
  // use Drush\Attributes as CLI;
  #[CLI\Command(name: 'devel-wizard:spell:devel_wizard_block_content_type')]
  #[CLI\Help(
    description: 'Creates a Block Type with all the bells and whistles.',
  )]
  #[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
  #[CLI\Argument(
    name: 'blockTypeId',
    description: 'The machine-name of the Block Type.',
  )]
  public function cmdAllInOneExecute(string $blockTypeId): void {
    $this->execute();
  }

  protected function buildSpellConfigurationFromInput(): array {
    $input = $this->input();
    $spellId = $this->getSpellIdFromInput();

    return match ($spellId) {
      'devel_wizard_block_content_type_admin_view' => [
        'machine_name' => $input->getArgument('blockTypeId'),
        'module' => [
          'machine_name' => 'app_core',
        ],
      ],
      'devel_wizard_block_content_type_behat',
      'devel_wizard_block_content_type_migration',
      'devel_wizard_block_content_type_user_role' => [
        'machine_name' => $input->getArgument('blockTypeId'),
      ],
      'devel_wizard_block_content_type_create' => [
        'values' => [
          'id' => $input->getArgument('blockTypeId'),
        ],
      ],
      'devel_wizard_block_content_type' => [
        'create' => [
          'values' => [
            'id' => $input->getArgument('blockTypeId'),
          ],
        ],
      ],
      default => [],
    };
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc