X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FEntity%2FDebugCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FEntity%2FDebugCommand.php;h=d041d56f74dedad2b97fdd325f573e7bc82dbdd2;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drupal/console/src/Command/Entity/DebugCommand.php b/vendor/drupal/console/src/Command/Entity/DebugCommand.php new file mode 100644 index 000000000..d041d56f7 --- /dev/null +++ b/vendor/drupal/console/src/Command/Entity/DebugCommand.php @@ -0,0 +1,96 @@ +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)); + } +}