Chris@0: entityManager = $entity_manager; 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: $container->get('entity.manager') 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 (!isset($this->derivatives)) { Chris@0: $this->getDerivativeDefinitions($base_plugin_definition); Chris@0: } Chris@0: if (isset($this->derivatives[$derivative_id])) { Chris@0: return $this->derivatives[$derivative_id]; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getDerivativeDefinitions($base_plugin_definition) { Chris@0: if (!isset($this->derivatives)) { Chris@0: // Add in the default plugin configuration and the resource type. Chris@0: foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { Chris@14: if ($entity_type->isInternal()) { Chris@14: continue; Chris@14: } Chris@14: Chris@0: $this->derivatives[$entity_type_id] = [ Chris@0: 'id' => 'entity:' . $entity_type_id, Chris@0: 'entity_type' => $entity_type_id, Chris@0: 'serialization_class' => $entity_type->getClass(), Chris@0: 'label' => $entity_type->getLabel(), Chris@0: ]; Chris@0: Chris@0: $default_uris = [ Chris@0: 'canonical' => "/entity/$entity_type_id/" . '{' . $entity_type_id . '}', Chris@0: 'create' => "/entity/$entity_type_id", Chris@0: ]; Chris@0: Chris@0: foreach ($default_uris as $link_relation => $default_uri) { Chris@0: // Check if there are link templates defined for the entity type and Chris@0: // use the path from the route instead of the default. Chris@0: if ($link_template = $entity_type->getLinkTemplate($link_relation)) { Chris@0: $this->derivatives[$entity_type_id]['uri_paths'][$link_relation] = $link_template; Chris@0: } Chris@0: else { Chris@0: $this->derivatives[$entity_type_id]['uri_paths'][$link_relation] = $default_uri; Chris@0: } Chris@0: } Chris@0: Chris@0: $this->derivatives[$entity_type_id] += $base_plugin_definition; Chris@0: } Chris@0: } Chris@0: return $this->derivatives; Chris@0: } Chris@0: Chris@0: }