Skip to content

Commit

Permalink
Stop asking for bundle in the field commands if the entity type isn't…
Browse files Browse the repository at this point in the history
… able to have bundles
  • Loading branch information
DieterHolvoet committed Jan 2, 2022
1 parent 786948b commit 7d016bc
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Drupal/Commands/field/EntityTypeBundleAskTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ protected function askBundle(): ?string
$bundleInfo = $this->entityTypeBundleInfo->getBundleInfo($entityTypeId);
$choices = [];

if (empty($bundleInfo)) {
if ($bundleEntityType) {
throw new \InvalidArgumentException(
t('Entity type with id \':entityType\' does not have any bundles.', [':entityType' => $entityTypeId])
);
}
if ($bundleEntityType && $bundleInfo === []) {
throw new \InvalidArgumentException(
t('Entity type with id \':entityType\' does not have any bundles.', [':entityType' => $entityTypeId])
);
}

return null;
if (!$bundleEntityType && count($bundleInfo) === 1) {
// eg. User
return $entityTypeId;
}

foreach ($bundleInfo as $bundle => $data) {
Expand Down

0 comments on commit 7d016bc

Please sign in to comment.