function FieldResolver::getPathPartPropertyName

Same name in other branches
  1. 8.9.x core/modules/jsonapi/src/Context/FieldResolver.php \Drupal\jsonapi\Context\FieldResolver::getPathPartPropertyName()
  2. 10 core/modules/jsonapi/src/Context/FieldResolver.php \Drupal\jsonapi\Context\FieldResolver::getPathPartPropertyName()
  3. 11.x core/modules/jsonapi/src/Context/FieldResolver.php \Drupal\jsonapi\Context\FieldResolver::getPathPartPropertyName()

Gets the property name from an entity typed or untyped path part.

A path part may contain an entity type specifier like `entity:node`. This extracts the actual property name. If an entity type is not specified, then the path part is simply returned. For example, both `foo` and `foo:bar` will return `foo`.

Parameters

string $part: A path part.

Return value

string The property name from a path part.

2 calls to FieldResolver::getPathPartPropertyName()
FieldResolver::isCandidateDefinitionProperty in core/modules/jsonapi/src/Context/FieldResolver.php
Determines if a path part targets a field property, not a subsequent field.
FieldResolver::isCandidateDefinitionReferenceProperty in core/modules/jsonapi/src/Context/FieldResolver.php
Determines if a path part targets a reference property.

File

core/modules/jsonapi/src/Context/FieldResolver.php, line 743

Class

FieldResolver
A service that evaluates external path expressions against Drupal fields.

Namespace

Drupal\jsonapi\Context

Code

protected static function getPathPartPropertyName($part) {
    return strpos($part, ':') !== FALSE ? explode(':', $part)[0] : $part;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.