function ContextAwarePluginInterface::assertMetadata

Asserts additional metadata for the selected data.

Allows the plugin to assert additional metadata that is in place when the plugin has been successfully executed. A typical use-case would be asserting the node type for a "Node is of type" condition. By doing so, sub-sequent executed plugins are aware of the metadata and can build upon it.

Implement this method, when the selected data definitions need to be refined. When the plugin's context definitions should be refined, implement ::refineContextDefinitions() instead.

Note that metadata is only asserted on configuration time. The plugin has to ensure that the run-time data matches the asserted configuration if it has been executed successfully.

Parameters

\Drupal\Core\TypedData\DataDefinitionInterface[] $selected_data: An array of data definitions for context that is mapped using a data selector, keyed by context name.

Return value

\Drupal\Core\TypedData\DataDefinitionInterface[] An array of modified data definitions, keyed as the passed array. Note data definitions need to be cloned *before* they are modified, such that the changes do not propagate unintentionally.

2 methods override ContextAwarePluginInterface::assertMetadata()
RulesActionBase::assertMetadata in src/Core/RulesActionBase.php
Asserts additional metadata for the selected data.
RulesConditionBase::assertMetadata in src/Core/RulesConditionBase.php
Asserts additional metadata for the selected data.

File

src/Context/ContextAwarePluginInterface.php, line 58

Class

ContextAwarePluginInterface
Rules extension of ContextAwarePluginInterface.

Namespace

Drupal\rules\Context

Code

public function assertMetadata(array $selected_data);