You are here

public function DataFetcher::fetchDefinitionByPropertyPath in Typed Data API enhancements 8

Fetches a data definition based upon the given property path.

Parameters

\Drupal\Core\TypedData\DataDefinitionInterface $data_definition: The data definition from which to retrieve a nested definition.

string $property_path: The property path string, e.g. "uid.entity.mail.value".

string $langcode: (optional) The language code used to get the argument value if the argument value should be translated. Defaults to NULL.

Return value

\Drupal\Core\TypedData\DataDefinitionInterface The data definition of the target.

Throws

\Drupal\typed_data\Exception\InvalidArgumentException Thrown if the given path is not valid for the given data; e.g., a not existing property is referenced.

Overrides DataFetcherInterface::fetchDefinitionByPropertyPath

1 call to DataFetcher::fetchDefinitionByPropertyPath()
DataFetcher::autocompletePropertyPath in src/DataFetcher.php
Provides autocomplete suggestions for an incomplete property path.

File

src/DataFetcher.php, line 107

Class

DataFetcher
Implementation of the data fetcher service.

Namespace

Drupal\typed_data

Code

public function fetchDefinitionByPropertyPath(DataDefinitionInterface $data_definition, $property_path, $langcode = NULL) {
  $sub_paths = explode('.', $property_path);
  return $this
    ->fetchDefinitionBySubPaths($data_definition, $sub_paths, $langcode);
}