function FieldResolver::isCandidateDefinitionProperty

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

Determines if a path part targets a field property, not a subsequent field.

Parameters

string $part: The path part.

\Drupal\Core\TypedData\ComplexDataDefinitionInterface[] $candidate_definitions: A list of targeted field item definitions which are specified by the path.

Return value

bool TRUE if the part is a property of one of the candidate definitions, FALSE otherwise.

1 call to FieldResolver::isCandidateDefinitionProperty()
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 688

Class

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

Namespace

Drupal\jsonapi\Context

Code

protected static function isCandidateDefinitionProperty($part, array $candidate_definitions) {
    $part = static::getPathPartPropertyName($part);
    foreach ($candidate_definitions as $definition) {
        $property_definitions = $definition->getPropertyDefinitions();
        foreach ($property_definitions as $property_name => $property_definition) {
            $property_name = $property_definition instanceof DataReferenceTargetDefinition ? "drupal_internal__{$property_name}" : $property_name;
            if ($part === $property_name) {
                return TRUE;
            }
        }
    }
    return FALSE;
}

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