X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FDebug%2FEntityCommand.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FDebug%2FEntityCommand.php;h=89656120f67203b744bcf85e9a685da5d0176d7e;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=0000000000000000000000000000000000000000;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/vendor/drupal/console/src/Command/Debug/EntityCommand.php b/vendor/drupal/console/src/Command/Debug/EntityCommand.php new file mode 100644 index 000000000..89656120f --- /dev/null +++ b/vendor/drupal/console/src/Command/Debug/EntityCommand.php @@ -0,0 +1,90 @@ +entityTypeRepository = $entityTypeRepository; + $this->entityTypeManager = $entityTypeManager; + parent::__construct(); + } + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('debug:entity') + ->setDescription($this->trans('commands.debug.entity.description')) + ->addArgument( + 'entity-type', + InputArgument::OPTIONAL, + $this->trans('commands.debug.entity.arguments.entity-type') + )->setAliases(['de']); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $entityType = $input->getArgument('entity-type'); + + $tableHeader = [ + $this->trans('commands.debug.entity.table-headers.entity-name'), + $this->trans('commands.debug.entity.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 + ]; + } + } + + $this->getIo()->table($tableHeader, array_values($tableRows)); + } +}