protected function ResourceTypeRepository::createResourceType in Layout Builder Symmetric Translations 8
Creates a ResourceType value object for the given entity type + bundle.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type to create a JSON:API resource type for.
string $bundle: The entity type bundle to create a JSON:API resource type for.
Return value
\Drupal\jsonapi\ResourceType\ResourceType A JSON:API resource type.
Overrides ResourceTypeRepository::createResourceType
File
- src/
ResourceTypeRepository.php, line 14
Class
Namespace
Drupal\layout_builder_stCode
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);
}