You are here

protected function FeedsRulesProcessor::entitySave in Feeds Rules 7

Pseudo save method for executing the rule set execution.

File

plugins/FeedsRulesProcessor.inc, line 55
Defines the Feeds Rules processor plugin.

Class

FeedsRulesProcessor
Feeds processor plugin to process a rules component for each feed items.

Code

protected function entitySave($entity) {

  // Invoke the action component, only if the action hasn't been executed
  // before.
  // (we do not use rules_invoke_component() because of its weird argument
  // passing).
  if (empty($entity->executed) && ($component = rules_get_cache('comp_' . $entity->component))) {
    $return = $component
      ->executeByArgs($entity->params);
    $entity->executed = time();
  }

  // Handle provided data, as it is provided as sole value array, we need to
  // rebuild the named keys.
  if (isset($return)) {
    $provides = $component
      ->providesVariables();
    $entity->provided = array_combine(array_keys($provides), $return);
  }
  else {
    $entity->provided = array();
  }

  // And save it.
  return entity_save('feeds_rules_action', $entity);
}