public static function ResourceIdentifier::fromEntity in JSON:API 8.2
Creates a ResourceIdentifier object.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity from which to create the resource identifier.
Return value
self A new ResourceIdentifier object.
1 call to ResourceIdentifier::fromEntity()
- EntityAccessDeniedHttpException::__construct in src/
Exception/ EntityAccessDeniedHttpException.php - EntityAccessDeniedHttpException constructor.
File
- src/
JsonApiResource/ ResourceIdentifier.php, line 374
Class
- ResourceIdentifier
- Represents a JSON:API resource identifier object.
Namespace
Drupal\jsonapi\JsonApiResourceCode
public static function fromEntity(EntityInterface $entity) {
/* @var \Drupal\jsonapi\ResourceType\ResourceTypeRepositoryInterface $resource_type_repository */
$resource_type_repository = \Drupal::service('jsonapi.resource_type.repository');
$resource_type = $resource_type_repository
->get($entity
->getEntityTypeId(), $entity
->bundle());
return new static($resource_type, $entity
->uuid());
}