You are here

protected function AvailabilityCalendarICalFeedsProcessor::map in Availability Calendars 7.5

Execute mapping on an item.

Parameters

\FeedsSource $source:

\FeedsParserResult $result:

object|null $target_item:

Return value

null

Throws

\EntityMalformedException

\Exception

File

./AvailabilityCalendarICalFeedsProcessor.inc, line 139

Class

AvailabilityCalendarICalFeedsProcessor
@class ICalendar processor for availability calendars.

Code

protected function map(FeedsSource $source, FeedsParserResult $result, $target_item = NULL) {

  // Static cache $targets as getMappingTargets() may be an expensive method.
  static $sources;
  if (!isset($sources[$this->id])) {
    $sources[$this->id] = feeds_importer($this->id)->parser
      ->getMappingSources();
  }
  static $targets;
  if (!isset($targets[$this->id])) {
    $targets[$this->id] = $this
      ->getMappingTargets();
  }

  /** @var \FeedsParser $parser */
  $parser = feeds_importer($this->id)->parser;
  foreach ($this->config['mappings'] as $mapping) {
    $value = $parser
      ->getSourceElement($source, $result, $mapping['source']);

    // Map the source element's value to the target.
    $this
      ->setTargetElement($source, $target_item, $mapping['target'], $value);
  }
  return $target_item;
}