/** * {@inheritdoc} */ protected function interact(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $entityDefinitionID = $input->getArgument('entity-definition-id'); $entityID = $input->getArgument('entity-id'); if (!$entityDefinitionID) { $entityTypes = $this->entityTypeRepository->getEntityTypeLabels(true); $entityType = $io->choice($this->trans('commands.entity.delete.questions.entity-type'), array_keys($entityTypes)); $entityDefinitionID = $io->choice($this->trans('commands.entity.delete.questions.entity-definition-id'), array_keys($entityTypes[$entityType])); $input->setArgument('entity-definition-id', $entityDefinitionID); } if (!$entityID) { $entityID = $io->ask($this->trans('commands.entity.delete.questions.entity-id')); $input->setArgument('entity-id', $entityID); } }
/** * @covers ::getEntityTypeFromClass * * @expectedException \Drupal\Core\Entity\Exception\AmbiguousEntityClassException * @expectedExceptionMessage Multiple entity types found for \Drupal\apple\Entity\Apple. */ public function testGetEntityTypeFromClassAmbiguous() { $boskoop = $this->prophesize(EntityTypeInterface::class); $boskoop->getOriginalClass()->willReturn('\\Drupal\\apple\\Entity\\Apple'); $boskoop->id()->willReturn('boskop'); $gala = $this->prophesize(EntityTypeInterface::class); $gala->getOriginalClass()->willReturn('\\Drupal\\apple\\Entity\\Apple'); $gala->id()->willReturn('gala'); $this->setUpEntityTypeDefinitions(['boskoop' => $boskoop, 'gala' => $gala]); $this->entityTypeRepository->getEntityTypeFromClass('\\Drupal\\apple\\Entity\\Apple'); }
/** * {@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)); }