function RulesState::saveNow

Saves the wrapper for the given selector.

2 calls to RulesState::saveNow()
RulesState::cleanUp in includes/rules.state.inc
Runs post-evaluation tasks, such as saving variables.
RulesState::save in includes/rules.state.inc
Remembers to save the wrapper on cleanup or does it now.

File

includes/rules.state.inc, line 229

Class

RulesState
The rules evaluation state.

Code

protected function saveNow($selector) {
    // Add the set of blocked elements for the recursion prevention.
    $previously_blocked = self::$blocked;
    self::$blocked += $this->save[$selector][1];
    // Actually save!
    $wrapper = $this->save[$selector][0];
    $entity = $wrapper->value();
    // When operating in hook_entity_insert() $entity->is_new might be still
    // set. In that case remove the flag to avoid causing another insert instead
    // of an update.
    if (!empty($entity->is_new) && $wrapper->getIdentifier()) {
        $entity->is_new = FALSE;
    }
    rules_log('Saved %selector of type %type.', array(
        '%selector' => $selector,
        '%type' => $wrapper->type(),
    ));
    $wrapper->save();
    // Restore the state's set of blocked elements.
    self::$blocked = $previously_blocked;
    unset($this->save[$selector]);
}