You are here

public function ExecutionMetadataState::fetchDefinitionByPropertyPath in Rules 8.3

Applies a data selector and returns the corresponding data definition.

Parameters

string $property_path: The property path, example: "node.title.value".

string $langcode: The language code.

Return value

\Drupal\Core\TypedData\DataDefinitionInterface A data definition if the property path could be applied.

Throws

\Drupal\rules\Exception\IntegrityException Thrown if the property path is invalid.

Overrides ExecutionMetadataStateInterface::fetchDefinitionByPropertyPath

File

src/Context/ExecutionMetadataState.php, line 88

Class

ExecutionMetadataState
The state used during configuration time holding data definitions.

Namespace

Drupal\rules\Context

Code

public function fetchDefinitionByPropertyPath($property_path, $langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED) {
  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 (isset($property_path[0]) && $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()
      ->fetchDefinitionBySubPaths($this
      ->getDataDefinition($var_name), $parts, $langcode);
  } catch (TypedDataException $e) {

    // Pass on the original exception in the exception trace.
    throw new IntegrityException($e
      ->getMessage(), 0, $e);
  }
}