You are here

protected function FeedsTermProcessor::entitySave in Feeds 7.2

Saves a term.

We de-array parent fields with only one item. This stops leftandright module from freaking out.

Overrides FeedsProcessor::entitySave

File

plugins/FeedsTermProcessor.inc, line 74
FeedsTermProcessor class.

Class

FeedsTermProcessor
Feeds processor plugin. Create taxonomy terms from feed items.

Code

protected function entitySave($term) {
  if (isset($term->parent)) {
    if (is_array($term->parent) && count($term->parent) == 1) {
      $term->parent = reset($term->parent);
    }
    if (isset($term->tid) && ($term->parent == $term->tid || is_array($term->parent) && in_array($term->tid, $term->parent))) {
      throw new FeedsValidationException(t("A term can't be its own child. GUID:@guid", array(
        '@guid' => $term->feeds_item->guid,
      )));
    }
  }
  taxonomy_term_save($term);
}