Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ResourceIdentifier.php

function 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\JsonApiResource

Code

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());
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal