You are here

public function LogProcessor::setTargetElement in Log entity 7

Override setTargetElement to operate on a target item that is a log.

File

includes/feeds/plugins/LogProcessor.inc, line 181
Class definition of LogProcessor.

Class

LogProcessor
Creates logs from feed items.

Code

public function setTargetElement(FeedsSource $source, $target_log, $target_element, $value) {
  switch ($target_element) {
    case 'created':
      $target_log->created = feeds_to_unixtime($value, REQUEST_TIME);
      break;
    case 'changed':

      // The 'changed' value will be set on the log in log_entity_presave().
      // This is because log_save() always overwrites this value (though
      // before invoking hook_entity_presave()).
      $target_log->feeds_item->log_changed = feeds_to_unixtime($value, REQUEST_TIME);
      break;
    case 'user_name':
      if ($user = user_load_by_name($value)) {
        $target_log->uid = $user->uid;
      }
      break;
    case 'user_mail':
      if ($user = user_load_by_mail($value)) {
        $target_log->uid = $user->uid;
      }
      break;
    default:
      parent::setTargetElement($source, $target_log, $target_element, $value);
      break;
  }
}