Skip to content
Snippets Groups Projects

Issue #3358377: Suggest possible entity types when no entity type is passed

9 files
+ 122
165
Compare changes
  • Side-by-side
  • Inline
Files
9
@@ -19,7 +19,7 @@ class EckBundleCreateCommands extends DrushCommands implements CustomEventAwareI
use BundleMachineNameAskTrait;
use CustomEventAwareTrait;
use ValidatorsTrait;
use EckEntityTypeTrait;
/**
* The entity type manager.
@@ -43,7 +43,7 @@ class EckBundleCreateCommands extends DrushCommands implements CustomEventAwareI
/**
* Create a new eck entity type.
*
* @param string $entityType
* @param string|null $entityType
* The machine name of the entity type.
* @param array $options
* The command options.
@@ -51,8 +51,6 @@ class EckBundleCreateCommands extends DrushCommands implements CustomEventAwareI
* @command eck:bundle:create
* @aliases eck-bundle-create,ebc
*
* @validate-eck-entity-type-argument entityType
*
* @option label
* The human-readable name of this entity bundle.
* This name must be unique.
@@ -74,7 +72,7 @@ class EckBundleCreateCommands extends DrushCommands implements CustomEventAwareI
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function create(string $entityType, array $options = [
public function create(?string $entityType = null, array $options = [
'label' => InputOption::VALUE_REQUIRED,
'machine-name' => InputOption::VALUE_REQUIRED,
'description' => InputOption::VALUE_OPTIONAL,
@@ -110,26 +108,24 @@ class EckBundleCreateCommands extends DrushCommands implements CustomEventAwareI
* @hook interact eck:bundle:create
*/
public function interact(InputInterface $input, OutputInterface $output, AnnotationData $annotationData): void {
$entityTypeId = $this->input->getArgument('entityType');
if (!$entityTypeId) {
return;
}
$this->input->setArgument(
'entityType',
$entityTypeId = $this->input->getArgument('entityType') ?? $this->askEckEntityType()
);
$this->validateEckEntityType($entityTypeId);
$this->input->setOption(
'label',
$this->input->getOption('label') ?? $this->askLabel()
);
'label',
$this->input->getOption('label') ?? $this->askLabel()
);
$this->input->setOption(
'machine-name',
$this->input->getOption('machine-name') ?? $this->askMachineName($entityTypeId)
);
'machine-name',
$this->input->getOption('machine-name') ?? $this->askMachineName($entityTypeId)
);
$this->input->setOption(
'description',
$this->input->getOption('description') ?? $this->askDescription()
);
'description',
$this->input->getOption('description') ?? $this->askDescription()
);
}
/**
Loading