public static function ResourceIdentifier::fromEntity in Drupal 9
Same name and namespace in other branches
- 8 core/modules/jsonapi/src/JsonApiResource/ResourceIdentifier.php \Drupal\jsonapi\JsonApiResource\ResourceIdentifier::fromEntity()
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 core/
modules/ jsonapi/ src/ Exception/ EntityAccessDeniedHttpException.php - EntityAccessDeniedHttpException constructor.
File
- core/
modules/ jsonapi/ src/ JsonApiResource/ ResourceIdentifier.php, line 379
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());
}