You are here

public function DateIcalFeedsParser::getSourceElement in Date iCal 7.2

Override FeedsParser::getSourceElement().

File

includes/DateIcalFeedsParser.inc, line 47
Basic classes.

Class

DateIcalFeedsParser
Parent class for Feeds integration.

Code

public function getSourceElement(FeedsSource $source, FeedsParserResult $result, $property_key) {

  // Allow parent method to handle any mappings based on the parent node.
  if (substr($property_key, 0, 7) == 'parent:') {
    return parent::getSourceElement($source, $result, $property_key);
  }

  // Otherwise retrieve the current DateIcalComponent from the DateIcalParserResult.
  if ($item = $result
    ->currentItem()) {
    if ($position = strpos($property_key, ':')) {
      $key = substr($property_key, 0, $position);
      $attribute = substr($property_key, ++$position);
    }
    else {
      $key = $property_key;
    }

    // and use listed handler to get source output
    $handler = $this::$sources[$property_key]['date_ical_parse_handler'];
    $property = $item
      ->getProperty($key);
    if (empty($property)) {

      // $property will be empty if the mapping is set up to parse optional source
      // components (e.g. RRULE), and this particular VEVENT doesn't have one.
      return '';
    }
    else {
      return $this
        ->{$handler}($property_key, $property, $item, $result, $source);
    }
  }
}