You are here

class ResourceTypeRepository in Layout Builder Symmetric Translations 8

Hierarchy

Expanded class hierarchy of ResourceTypeRepository

1 file declares its use of ResourceTypeRepository
LayoutBuilderEntityViewDisplayTest.php in tests/src/Functional/Jsonapi/LayoutBuilderEntityViewDisplayTest.php

File

src/ResourceTypeRepository.php, line 9

Namespace

Drupal\layout_builder_st
View source
class ResourceTypeRepository extends CoreResourceTypeRepository {

  /**
   * {@inheritdoc}
   */
  protected function createResourceType(EntityTypeInterface $entity_type, $bundle) {
    if ($entity_type
      ->id() === 'entity_view_display') {

      // In order to prevent the raw layout section data from being exposed via
      // the HTTP API, we need to make sure that the entity type is using the
      // core entity class for this resource type, rather than our specialized
      // one. However, we only want this to be a momentary override; we do NOT
      // want it to persist in the entity type manager's cached entity type
      // definitions. So, to prevent that from happening, we clone the entity
      // type definition, modify it, and send the modified doppelgänger to the
      // parent method.
      $entity_type = clone $entity_type;
      $entity_type
        ->setClass(LayoutBuilderEntityViewDisplay::class);
    }
    return parent::createResourceType($entity_type, $bundle);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ResourceTypeRepository::$cache protected property The cache backend.
ResourceTypeRepository::$cacheTags protected property Cache tags used for caching the repository.
ResourceTypeRepository::$entityFieldManager protected property The entity field manager.
ResourceTypeRepository::$entityTypeBundleInfo protected property The bundle manager.
ResourceTypeRepository::$entityTypeManager protected property The entity type manager.
ResourceTypeRepository::$eventDispatcher protected property The event dispatcher.
ResourceTypeRepository::all public function Gets all JSON:API resource types. Overrides ResourceTypeRepositoryInterface::all
ResourceTypeRepository::calculateRelatableResourceTypes protected function Calculates relatable JSON:API resource types for a given resource type.
ResourceTypeRepository::createResourceType protected function Creates a ResourceType value object for the given entity type + bundle. Overrides ResourceTypeRepository::createResourceType
ResourceTypeRepository::get public function Gets a specific JSON:API resource type based on entity type ID and bundle. Overrides ResourceTypeRepositoryInterface::get
ResourceTypeRepository::getAllBundlesForEntityType protected function Gets all bundle IDs for a given entity type.
ResourceTypeRepository::getAllFieldNames protected function Gets all field names for a given entity type and bundle.
ResourceTypeRepository::getByTypeName public function Gets a specific JSON:API resource type based on a supplied typename. Overrides ResourceTypeRepositoryInterface::getByTypeName
ResourceTypeRepository::getFieldMapping Deprecated protected function Gets the field mapping for the given field names and entity type + bundle.
ResourceTypeRepository::getFields protected function Gets the field mapping for the given field names and entity type + bundle. 1
ResourceTypeRepository::getRelatableResourceTypesFromFieldDefinition protected function Get relatable resource types from a field definition.
ResourceTypeRepository::isLocatableResourceType protected static function Whether an entity type + bundle maps to a locatable resource type.
ResourceTypeRepository::isMutableResourceType protected static function Whether an entity type + bundle maps to a mutable resource type.
ResourceTypeRepository::isReferenceFieldDefinition protected function Determines if a given field definition is a reference field.
ResourceTypeRepository::isVersionableResourceType protected static function Whether an entity type is a versionable resource type.
ResourceTypeRepository::__construct public function Instantiates a ResourceTypeRepository object.