function FieldResolver::constructInternalPath

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

Expands the internal path with the "entity" keyword.

Parameters

string[] $references: The resolved internal field names of all entity references.

string[] $property_path: (optional) A sub-property path for the last field in the path.

Return value

string The expanded and imploded path.

1 call to FieldResolver::constructInternalPath()
FieldResolver::resolveInternalEntityQueryPath in core/modules/jsonapi/src/Context/FieldResolver.php
Resolves external field expressions into entity query compatible paths.

File

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

Class

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

Namespace

Drupal\jsonapi\Context

Code

protected function constructInternalPath(array $references, array $property_path = []) {
    // Reconstruct the path parts that are referencing sub-properties.
    $field_path = implode('.', array_map(function ($part) {
        return str_replace('drupal_internal__', '', $part);
    }, $property_path));
    // This rebuilds the path from the real, internal field names that have
    // been traversed so far. It joins them with the "entity" keyword as
    // required by the entity query system.
    $entity_path = implode('.', $references);
    // Reconstruct the full path to the final reference field.
    return empty($field_path) ? $entity_path : $entity_path . '.' . $field_path;
}

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