function RulesState::mergeSaveVariables

Merges info from the given state into the existing state.

Merges the info about to-be-saved variables from the given state into the existing state. Therefore we can aggregate saves from invoked components. Merged-in saves are removed from the given state, but not-mergeable saves remain there.

Parameters

$state: The state for which to merge the to be saved variables in.

$component: The component which has been invoked, thus needs to be blocked for the merged in saves.

$settings: The settings of the element that invoked the component. Contains information about variable/selector mappings between the states.

File

includes/rules.state.inc, line 268

Class

RulesState
The rules evaluation state.

Code

public function mergeSaveVariables(RulesState $state, RulesPlugin $component, $settings) {
    // For any saves that we take over, also block the component.
    $this->block($component);
    foreach ($state->save
        ->getArrayCopy() as $selector => $data) {
        $parts = explode(':', $selector, 2);
        // Adapt the selector to fit for the parent state and move the wrapper.
        if (isset($settings[$parts[0] . ':select'])) {
            $parts[0] = $settings[$parts[0] . ':select'];
            $this->save(implode(':', $parts), $data[0], FALSE);
            unset($state->save[$selector]);
        }
    }
    $this->unblock($component);
}