protected function ContextHandlerTrait::getSelectedData in Rules 8.3
Gets definitions of all selected data at configuration time.
Parameters
\Drupal\rules\Context\ExecutionMetadataStateInterface $metadata_state: The metadata state.
Return value
\Drupal\Core\TypedData\DataDefinitionInterface[] An array of data definitions for context that is mapped using a data selector, keyed by context name.
2 calls to ContextHandlerTrait::getSelectedData()
- ContextHandlerTrait::assertMetadata in src/
Context/ ContextHandlerTrait.php - Asserts additional metadata.
- ContextHandlerTrait::prepareContextWithMetadata in src/
Context/ ContextHandlerTrait.php - Prepares plugin context based upon the set context configuration.
File
- src/
Context/ ContextHandlerTrait.php, line 154
Class
- ContextHandlerTrait
- Provides methods for handling context based on the plugin configuration.
Namespace
Drupal\rules\ContextCode
protected function getSelectedData(ExecutionMetadataStateInterface $metadata_state) {
$selected_data = [];
// Collected the definitions of selected data for refining context
// definitions.
if (isset($this->configuration['context_mapping'])) {
// If no state is available, we need to fetch at least the definitions of
// selected data for refining context.
foreach ($this->configuration['context_mapping'] as $name => $selector) {
try {
$selected_data[$name] = $this
->getMappedDefinition($name, $metadata_state);
} catch (IntegrityException $e) {
// Ignore invalid data selectors here, such that context gets refined
// as far as possible still and can be respected by the UI when fixing
// broken selectors.
}
}
}
return $selected_data;
}