Skip to content

Commit

Permalink
Only show fieldable entity types when asking for entity type in field…
Browse files Browse the repository at this point in the history
… commands (#4970)
  • Loading branch information
DieterHolvoet committed Jan 1, 2022
1 parent 5a1c1b2 commit 52fdffe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Drupal/Commands/field/EntityTypeBundleAskTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace Drush\Drupal\Commands\field;

use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Symfony\Component\Console\Input\InputInterface;

use function t;
Expand All @@ -17,7 +19,12 @@ trait EntityTypeBundleAskTrait
{
protected function askEntityType(): ?string
{
$entityTypeDefinitions = $this->entityTypeManager->getDefinitions();
$entityTypeDefinitions = array_filter(
$this->entityTypeManager->getDefinitions(),
function (EntityTypeInterface $entityType) {
return $entityType->entityClassImplements(FieldableEntityInterface::class);
}
);
$choices = [];

foreach ($entityTypeDefinitions as $entityTypeDefinition) {
Expand Down

0 comments on commit 52fdffe

Please sign in to comment.