public function DataFetcher::fetchDataByPropertyPath in Typed Data API enhancements 8
Fetches data based upon the given property path.
Parameters
\Drupal\Core\TypedData\TypedDataInterface $typed_data: The data from which to select a value.
string $property_path: The property path string, e.g. "uid.entity.mail.value".
\Drupal\Core\Render\BubbleableMetadata|null $bubbleable_metadata: (optional) An object to which required bubbleable metadata will be added.
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\TypedDataInterface The variable wrapped as typed data.
Throws
\Drupal\Core\TypedData\Exception\MissingDataException Thrown if the data cannot be fetched due to missing data; e.g., unset properties or list items.
\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::fetchDataByPropertyPath
File
- src/
DataFetcher.php, line 30
Class
- DataFetcher
- Implementation of the data fetcher service.
Namespace
Drupal\typed_dataCode
public function fetchDataByPropertyPath(TypedDataInterface $typed_data, $property_path, BubbleableMetadata $bubbleable_metadata = NULL, $langcode = NULL) {
$sub_paths = explode('.', $property_path);
return $this
->fetchDataBySubPaths($typed_data, $sub_paths, $bubbleable_metadata, $langcode);
}