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

Breadcrumb

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

function ResourceObject::extractFieldsFromEntity

Extracts the entity's fields.

Parameters

\Drupal\jsonapi\ResourceType\ResourceType $resource_type: The JSON:API resource type of the given entity.

\Drupal\Core\Entity\EntityInterface $entity: The entity from which fields should be extracted.

Return value

mixed|\Drupal\Core\Field\FieldItemListInterface[] If the resource object represents a content entity, the fields will be objects satisfying FieldItemListInterface. If it represents a config entity, the fields will be scalar values or arrays.

3 calls to ResourceObject::extractFieldsFromEntity()
LabelOnlyResourceObject::extractFieldsFromEntity in core/modules/jsonapi/src/JsonApiResource/LabelOnlyResourceObject.php
Extracts the entity's fields.
LabelOnlyResourceObject::extractFieldsFromEntity in core/modules/jsonapi/src/JsonApiResource/LabelOnlyResourceObject.php
Extracts the entity's fields.
ResourceObject::createFromEntity in core/modules/jsonapi/src/JsonApiResource/ResourceObject.php
Creates a new ResourceObject from an entity.
1 method overrides ResourceObject::extractFieldsFromEntity()
LabelOnlyResourceObject::extractFieldsFromEntity in core/modules/jsonapi/src/JsonApiResource/LabelOnlyResourceObject.php
Extracts the entity's fields.

File

core/modules/jsonapi/src/JsonApiResource/ResourceObject.php, line 240

Class

ResourceObject
Represents a JSON:API resource object.

Namespace

Drupal\jsonapi\JsonApiResource

Code

protected static function extractFieldsFromEntity(ResourceType $resource_type, EntityInterface $entity) {
    assert($entity instanceof ContentEntityInterface || $entity instanceof ConfigEntityInterface);
    return $entity instanceof ContentEntityInterface ? static::extractContentEntityFields($resource_type, $entity) : static::extractConfigEntityFields($resource_type, $entity);
}

API Navigation

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