4 * Contains \Drupal\Console\Command\Debug\EntityCommand.
7 namespace Drupal\Console\Command\Debug;
9 use Symfony\Component\Console\Input\InputArgument;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
12 use Drupal\Console\Core\Command\Command;
13 use Drupal\Core\Entity\EntityTypeRepository;
14 use Drupal\Core\Entity\EntityTypeManagerInterface;
16 class EntityCommand extends Command
19 * @var EntityTypeRepository
21 protected $entityTypeRepository;
24 * @var EntityTypeManagerInterface
26 protected $entityTypeManager;
29 * EntityCommand constructor.
31 * @param EntityTypeRepository $entityTypeRepository
32 * @param EntityTypeManagerInterface $entityTypeManager
34 public function __construct(
35 EntityTypeRepository $entityTypeRepository,
36 EntityTypeManagerInterface $entityTypeManager
38 $this->entityTypeRepository = $entityTypeRepository;
39 $this->entityTypeManager = $entityTypeManager;
40 parent::__construct();
45 protected function configure()
48 ->setName('debug:entity')
49 ->setDescription($this->trans('commands.debug.entity.description'))
52 InputArgument::OPTIONAL,
53 $this->trans('commands.debug.entity.arguments.entity-type')
54 )->setAliases(['de']);
60 protected function execute(InputInterface $input, OutputInterface $output)
62 $entityType = $input->getArgument('entity-type');
65 $this->trans('commands.debug.entity.table-headers.entity-name'),
66 $this->trans('commands.debug.entity.table-headers.entity-type')
70 $entityTypesLabels = $this->entityTypeRepository->getEntityTypeLabels(true);
73 $entityTypes = [$entityType => $entityType];
75 $entityTypes = array_keys($entityTypesLabels);
78 foreach ($entityTypes as $entityTypeId) {
79 $entities = array_keys($entityTypesLabels[$entityTypeId]);
80 foreach ($entities as $entity) {
81 $tableRows[$entity] = [
88 $this->getIo()->table($tableHeader, array_values($tableRows));