You are here

public function RulesActionBase::assertMetadata in Rules 8.3

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.

Overrides ContextAwarePluginInterface::assertMetadata

File

src/Core/RulesActionBase.php, line 54

Class

RulesActionBase
Base class for rules actions.

Namespace

Drupal\rules\Core

Code

public function assertMetadata(array $selected_data) {

  // Nothing to assert by default.
  return [];
}