function RulesActionBase::execute

Overrides ExecutableInterface::execute

2 methods override RulesActionBase::execute()
EntityCreate::execute in src/Plugin/RulesAction/EntityCreate.php
Executes the plugin.
RulesComponentAction::execute in src/Plugin/RulesAction/RulesComponentAction.php
Executes the plugin.

File

src/Core/RulesActionBase.php, line 135

Class

RulesActionBase
Base class for rules actions.

Namespace

Drupal\rules\Core

Code

public function execute() {
    // Provide a reasonable default implementation that calls doExecute() while
    // passing the defined context as arguments.
    $args = [];
    foreach ($this->getContextDefinitions() as $name => $definition) {
        $value = $this->getContextValue($name);
        $type = $definition->toArray()['type'];
        if (substr($type, 0, 6) == 'entity') {
            if (is_array($value) && is_string($value[0])) {
                $value = array_map([
                    $this,
                    'upcastEntityId',
                ], $value, array_fill(0, count($value), $type));
            }
            elseif (is_string($value)) {
                $value = $this->upcastEntityId($value, $type);
            }
        }
        $args[$name] = $value;
    }
    call_user_func_array([
        $this,
        'doExecute',
    ], $args);
}