You are here

protected function ContextHandlerTrait::getMappedDefinition in Rules 8.3

Gets the definition of the data that is mapped to the given context.

Parameters

string $context_name: The name of the context.

\Drupal\rules\Context\ExecutionMetadataStateInterface $metadata_state: The metadata state containing metadata about available variables.

Return value

\Drupal\Core\TypedData\DataDefinitionInterface|null A data definition if the property path could be applied, or NULL if the context is not mapped.

Throws

\Drupal\rules\Exception\IntegrityException Thrown if the data selector that is configured for the context is invalid.

2 calls to ContextHandlerTrait::getMappedDefinition()
ContextHandlerIntegrityTrait::checkContextConfigIntegrity in src/Context/ContextHandlerIntegrityTrait.php
Performs the integrity check.
ContextHandlerTrait::getSelectedData in src/Context/ContextHandlerTrait.php
Gets definitions of all selected data at configuration time.

File

src/Context/ContextHandlerTrait.php, line 191

Class

ContextHandlerTrait
Provides methods for handling context based on the plugin configuration.

Namespace

Drupal\rules\Context

Code

protected function getMappedDefinition($context_name, ExecutionMetadataStateInterface $metadata_state) {
  if (isset($this->configuration['context_mapping'][$context_name])) {
    return $metadata_state
      ->fetchDefinitionByPropertyPath($this->configuration['context_mapping'][$context_name]);
  }
}