devel_wizard-2.x-dev/src/Commands/NodeTypeSpellCommands.php
src/Commands/NodeTypeSpellCommands.php
<?php
declare(strict_types=1);
namespace Drupal\devel_wizard\Commands;
use Drush\Attributes as CLI;
use Drush\Boot\DrupalBootLevels;
class NodeTypeSpellCommands extends SpellCommandsBase {
/**
* @noinspection PhpUnusedParameterInspection
*/
#[CLI\Command(name: 'devel-wizard:spell:devel_wizard_node_type_admin_view')]
#[CLI\Help(
description: 'Creates a view for administrators for an existing Content type.',
)]
#[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
#[CLI\Argument(
name: 'nodeTypeId',
description: 'The machine-name of the Content Type.',
)]
public function cmdAdminViewExecute(string $nodeTypeId): void {
$this->execute();
}
/**
* @noinspection PhpUnusedParameterInspection
*/
#[CLI\Command(name: 'devel-wizard:spell:devel_wizard_node_type_behat')]
#[CLI\Help(
description: 'Generates Behat tests for an existing Content type.',
)]
#[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
#[CLI\Argument(
name: 'nodeTypeId',
description: 'The machine-name of the Content Type.',
)]
public function cmdBehatExecute(string $nodeTypeId): void {
$this->execute();
}
/**
* @noinspection PhpUnusedParameterInspection
*/
#[CLI\Command(name: 'devel-wizard:spell:devel_wizard_node_type_create')]
#[CLI\Help(
description: 'Creates a new Content type without any extra.',
)]
#[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
#[CLI\Argument(
name: 'nodeTypeId',
description: 'The machine-name of the new Content Type.',
)]
public function cmdCreateExecute(string $nodeTypeId): void {
$this->execute();
}
/**
* @noinspection PhpUnusedParameterInspection
*/
#[CLI\Command(name: 'devel-wizard:spell:devel_wizard_node_type_migration')]
#[CLI\Help(
description: 'Creates migration definitions and data sources for an existing Content type.',
)]
#[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
#[CLI\Argument(
name: 'nodeTypeId',
description: 'The machine-name of the new Content Type.',
)]
public function cmdMigrationExecute(string $nodeTypeId): void {
$this->execute();
}
/**
* @noinspection PhpUnusedParameterInspection
*/
#[CLI\Command(name: 'devel-wizard:spell:devel_wizard_node_type_user_role')]
#[CLI\Help(
description: 'Creates a new user role which grants full control over a specific Content type.',
)]
#[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
#[CLI\Argument(
name: 'nodeTypeId',
description: 'The machine-name of the new Content Type.',
)]
public function cmdUserRoleExecute(string $nodeTypeId): void {
$this->execute();
}
/**
* @noinspection PhpUnusedParameterInspection
*/
#[CLI\Command(name: 'devel-wizard:spell:devel_wizard_node_type')]
#[CLI\Help(
description: 'Creates a Content type with all the bells and whistles.',
)]
#[CLI\Bootstrap(level: DrupalBootLevels::FULL)]
#[CLI\Argument(
name: 'nodeTypeId',
description: 'The machine-name of the Content Type.',
)]
public function cmdAllInOneExecute(string $nodeTypeId): void {
$this->execute();
}
protected function buildSpellConfigurationFromInput(): array {
$input = $this->input();
$spellId = $this->getSpellIdFromInput();
return match ($spellId) {
'devel_wizard_node_type_admin_view' => [
'machine_name' => $input->getArgument('nodeTypeId'),
'module' => [
'machine_name' => 'app_core',
],
],
'devel_wizard_node_type_create' => [
'values' => [
'type' => $input->getArgument('nodeTypeId'),
],
],
'devel_wizard_node_type_behat',
'devel_wizard_node_type_migration',
'devel_wizard_node_type_user_role' => [
'machine_name' => $input->getArgument('nodeTypeId'),
],
'devel_wizard_node_type' => [
'create' => [
'values' => [
'type' => $input->getArgument('nodeTypeId'),
],
],
],
default => [],
};
}
}
