public function ExecutionState::fetchDataByPropertyPath in Rules 8.3
Returns a value as specified in the selector.
Parameters
string $property_path: The property path string starting with a variable name; e.g., "node.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\TypedDataInterface The variable wrapped as typed data.
Throws
\Drupal\rules\Exception\EvaluationException Throws an EvaluationException in case the selector cannot be applied.
Overrides ExecutionStateInterface::fetchDataByPropertyPath
1 call to ExecutionState::fetchDataByPropertyPath()
- ExecutionState::autoSave in src/
Context/ ExecutionState.php - Saves all variables that have been marked for auto saving.
File
- src/
Context/ ExecutionState.php, line 150
Class
- ExecutionState
- The rules execution state.
Namespace
Drupal\rules\ContextCode
public function fetchDataByPropertyPath($property_path, $langcode = NULL) {
try {
// Support global context names as variable name by ignoring points in
// the service name; e.g. @user.current_user_context:current_user.name.
if ($property_path[0] == '@') {
list($service, $property_path) = explode(':', $property_path, 2);
}
$parts = explode('.', $property_path);
$var_name = array_shift($parts);
if (isset($service)) {
$var_name = $service . ':' . $var_name;
}
return $this
->getDataFetcher()
->fetchDataBySubPaths($this
->getVariable($var_name), $parts, $langcode);
} catch (InvalidArgumentException $e) {
// Pass on the original exception in the exception trace.
throw new EvaluationException($e
->getMessage(), 0, $e);
} catch (MissingDataException $e) {
// Pass on the original exception in the exception trace.
throw new EvaluationException($e
->getMessage(), 0, $e);
}
}