4 * Contains \Drupal\Console\Command\Entity\DebugCommand.
7 namespace Drupal\Console\Command\Entity;
9 use Symfony\Component\Console\Input\InputArgument;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
12 use Symfony\Component\Console\Command\Command;
13 use Drupal\Core\Entity\EntityTypeRepository;
14 use Drupal\Core\Entity\EntityTypeManagerInterface;
15 use Drupal\Console\Core\Command\Shared\CommandTrait;
16 use Drupal\Console\Core\Style\DrupalStyle;
18 class DebugCommand extends Command
23 * @var EntityTypeRepository
25 protected $entityTypeRepository;
28 * @var EntityTypeManagerInterface
30 protected $entityTypeManager;
33 * DeleteCommand constructor.
35 * @param EntityTypeRepository $entityTypeRepository
36 * @param EntityTypeManagerInterface $entityTypeManager
38 public function __construct(
39 EntityTypeRepository $entityTypeRepository,
40 EntityTypeManagerInterface $entityTypeManager
42 $this->entityTypeRepository = $entityTypeRepository;
43 $this->entityTypeManager = $entityTypeManager;
44 parent::__construct();
49 protected function configure()
52 ->setName('entity:debug')
53 ->setDescription($this->trans('commands.entity.debug.description'))
56 InputArgument::OPTIONAL,
57 $this->trans('commands.entity.debug.arguments.entity-type')
64 protected function execute(InputInterface $input, OutputInterface $output)
66 $io = new DrupalStyle($input, $output);
68 $entityType = $input->getArgument('entity-type');
71 $this->trans('commands.entity.debug.table-headers.entity-name'),
72 $this->trans('commands.entity.debug.table-headers.entity-type')
76 $entityTypesLabels = $this->entityTypeRepository->getEntityTypeLabels(true);
79 $entityTypes = [$entityType => $entityType];
81 $entityTypes = array_keys($entityTypesLabels);
84 foreach ($entityTypes as $entityTypeId) {
85 $entities = array_keys($entityTypesLabels[$entityTypeId]);
86 foreach ($entities as $entity) {
87 $tableRows[$entity] = [
94 $io->table($tableHeader, array_values($tableRows));