You are here

class FeedsTermElement in Feeds 6

Same name and namespace in other branches
  1. 7.2 plugins/FeedsParser.inc \FeedsTermElement
  2. 7 plugins/FeedsParser.inc \FeedsTermElement

Encapsulates a taxonomy style term object.

Objects of this class can be turned into a taxonomy term style arrays by casting them.

$term_object = new FeedsTermElement($term_array);
$term_array = (array) $term_object;

Hierarchy

Expanded class hierarchy of FeedsTermElement

File

plugins/FeedsParser.inc, line 158

View source
class FeedsTermElement extends FeedsElement {
  public $tid, $vid, $name, $description, $weight;

  /**
   * @param $term
   *   An array or a stdClass object that is a Drupal taxonomy term.
   */
  public function __construct($term) {
    if (is_array($term)) {
      parent::__construct($term['name']);
      foreach ($this as $key => $value) {
        $this->{$key} = isset($term[$key]) ? $term[$key] : NULL;
      }
    }
    elseif (is_object($term)) {
      parent::__construct($term->name);
      foreach ($this as $key => $value) {
        $this->{$key} = isset($term->{$key}) ? $term->{$key} : NULL;
      }
    }
  }

  /**
   * Use $name as $value.
   */
  public function getValue() {
    return $this->name;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeedsElement::$value protected property
FeedsElement::__toString public function 1
FeedsTermElement::$tid public property
FeedsTermElement::getValue public function Use $name as $value. Overrides FeedsElement::getValue
FeedsTermElement::__construct public function Overrides FeedsElement::__construct 1