public function EntityCreate::refineContextDefinitions in Rules 8.3
Refines used and provided context definitions based upon context values.
When a plugin is configured half-way or even fully, some context values are already available upon which the definition of subsequent or provided context can be refined.
Implement this method, when the plugin's context definitions need to be refined. When the selected data definitions should be refined, implement ::assertMetadata() instead.
Note that context gets refined at configuration and execution time of the plugin.
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.
Overrides RulesActionBase::refineContextDefinitions
File
- src/
Plugin/ RulesAction/ EntityCreate.php, line 77
Class
- EntityCreate
- Provides a generic 'Create a new entity' action.
Namespace
Drupal\rules\Plugin\RulesActionCode
public function refineContextDefinitions(array $selected_data) {
if ($type = $this->entityTypeId) {
$data_type = "entity:{$type}";
if ($this->bundleKey && ($bundle = $this
->getContextValue($this->bundleKey))) {
$data_type .= ":{$bundle}";
}
$this->pluginDefinition['provides'][$type . '_created']
->setDataType($data_type);
}
}