Chris@0: basePluginId = $base_plugin_id; Chris@0: $this->entityManager = $entity_manager; Chris@0: $this->viewsData = $views_data; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public static function create(ContainerInterface $container, $base_plugin_id) { Chris@0: return new static( Chris@0: $base_plugin_id, Chris@0: $container->get('entity.manager'), Chris@0: $container->get('views.views_data') Chris@0: ); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { Chris@0: if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) { Chris@0: return $this->derivatives[$derivative_id]; Chris@0: } Chris@0: $this->getDerivativeDefinitions($base_plugin_definition); Chris@0: return $this->derivatives[$derivative_id]; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getDerivativeDefinitions($base_plugin_definition) { Chris@0: foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { Chris@0: // Just add support for entity types which have a views integration. Chris@0: if (($base_table = $entity_type->getBaseTable()) && $this->viewsData->get($base_table) && $this->entityManager->hasHandler($entity_type_id, 'view_builder')) { Chris@0: $this->derivatives[$entity_type_id] = [ Chris@0: 'id' => 'entity:' . $entity_type_id, Chris@0: 'provider' => 'views', Chris@0: 'title' => $entity_type->getLabel(), Chris@0: 'help' => t('Display the @label', ['@label' => $entity_type->getLabel()]), Chris@0: 'base' => [$entity_type->getDataTable() ?: $entity_type->getBaseTable()], Chris@0: 'entity_type' => $entity_type_id, Chris@0: 'display_types' => ['normal'], Chris@0: 'class' => $base_plugin_definition['class'], Chris@0: ]; Chris@0: } Chris@0: } Chris@0: Chris@0: return $this->derivatives; Chris@0: } Chris@0: Chris@0: }