protected function ContextHandlerTrait::assertMetadata in Rules 8.3
Asserts additional metadata.
Parameters
\Drupal\Core\Plugin\ContextAwarePluginInterface $plugin: The context aware plugin.
\Drupal\rules\Context\ExecutionMetadataStateInterface $metadata_state: The execution metadata state.
2 calls to ContextHandlerTrait::assertMetadata()
- ActionExpression::prepareExecutionMetadataState in src/
Plugin/ RulesExpression/ ActionExpression.php - Prepares the execution metadata state by adding metadata to it.
- ConditionExpression::prepareExecutionMetadataState in src/
Plugin/ RulesExpression/ ConditionExpression.php - Prepares the execution metadata state by adding metadata to it.
File
- src/
Context/ ContextHandlerTrait.php, line 261
Class
- ContextHandlerTrait
- Provides methods for handling context based on the plugin configuration.
Namespace
Drupal\rules\ContextCode
protected function assertMetadata(CoreContextAwarePluginInterface $plugin, ExecutionMetadataStateInterface $metadata_state) {
// If the plugin does not implement the Rules-enhanced interface, skip this.
if (!$plugin instanceof ContextAwarePluginInterface) {
return;
}
$changed_definitions = $plugin
->assertMetadata($this
->getSelectedData($metadata_state));
// Reverse the mapping and apply the changes.
foreach ($changed_definitions as $context_name => $definition) {
$selector = $this->configuration['context_mapping'][$context_name];
// @todo Deal with selectors matching not a context name.
if (strpos($selector, '.') === FALSE) {
$metadata_state
->setDataDefinition($selector, $definition);
}
}
}