You are here

public function ResourceObjectEntityLoaderTrait::loadEntityFromResourceObject in JSON:API Hypermedia 8

Gets the entity represented by the given resource object.

Parameters

\Drupal\jsonapi\JsonApiResource\ResourceObject $resource_object: The resource object.

Return value

\Drupal\Core\Entity\EntityInterface|null The represented entity or NULL if the entity does not exist.

Throws

\Drupal\Core\Entity\EntityStorageException Thrown in case the requested entity type does not support UUIDs.

2 calls to ResourceObjectEntityLoaderTrait::loadEntityFromResourceObject()
EntityPublishedInterfaceLinkProvider::getLink in examples/Plugin/jsonapi_hypermedia/LinkProvider/EntityPublishedInterfaceLinkProvider.php
Adds, alters or removes hyperlinks from a link collection.
MutableResourceTypeLinkProvider::getLink in examples/Plugin/jsonapi_hypermedia/LinkProvider/MutableResourceTypeLinkProvider.php
Adds, alters or removes hyperlinks from a link collection.

File

examples/Plugin/jsonapi_hypermedia/LinkProvider/ResourceObjectEntityLoaderTrait.php, line 44

Class

ResourceObjectEntityLoaderTrait
Trait for loading the entity represented by a resource object.

Namespace

Drupal\jsonapi_hypermedia\Plugin\jsonapi_hypermedia\LinkProvider

Code

public function loadEntityFromResourceObject(ResourceObject $resource_object) {
  return $this->entityRepository
    ->loadEntityByUuid($resource_object
    ->getResourceType(), $resource_object
    ->getId());
}