entityTypeRepository = $entityTypeRepository; $this->entityTypeManager = $entityTypeManager; parent::__construct(); } /** * {@inheritdoc} */ protected function configure() { $this ->setName('entity:debug') ->setDescription($this->trans('commands.entity.debug.description')) ->addArgument( 'entity-type', InputArgument::OPTIONAL, $this->trans('commands.entity.debug.arguments.entity-type') ); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $entityType = $input->getArgument('entity-type'); $tableHeader = [ $this->trans('commands.entity.debug.table-headers.entity-name'), $this->trans('commands.entity.debug.table-headers.entity-type') ]; $tableRows = []; $entityTypesLabels = $this->entityTypeRepository->getEntityTypeLabels(true); if ($entityType) { $entityTypes = [$entityType => $entityType]; } else { $entityTypes = array_keys($entityTypesLabels); } foreach ($entityTypes as $entityTypeId) { $entities = array_keys($entityTypesLabels[$entityTypeId]); foreach ($entities as $entity) { $tableRows[$entity] = [ $entity, $entityTypeId ]; } } $io->table($tableHeader, array_values($tableRows)); } }