You are here

class Notifications_Taxonomy_Term_Subscription in Notifications 7

Subscription to simple taxonomy term

Hierarchy

Expanded class hierarchy of Notifications_Taxonomy_Term_Subscription

1 string reference to 'Notifications_Taxonomy_Term_Subscription'
notifications_tags_notifications in notifications_tags/notifications_tags.module
Implementation of hook_notifications().

File

notifications_tags/notifications_tags.inc, line 200
Drupal Notifications Framework - Default class file

View source
class Notifications_Taxonomy_Term_Subscription extends Notifications_Subscription_Simple {

  /**
   * Get proper name
   */
  public function get_name() {
    if (isset($this->name)) {
      return $this->name;
    }
    elseif ($term = $this
      ->get_field('term:tid')
      ->drupal_object()) {
      return t('Content tagged with @term', array(
        '@term' => $term->name,
      ));
    }
    else {
      parent::get_name();
    }
  }

  /**
   * Add term object
   */
  public function add_term($term) {
    $this
      ->add_field('term:tid', $term->tid);
    return $this;
  }

  /**
   * Add term by name (and optional vid)
   */
  public function add_term_by_name($name, $vid = NULL) {
    $conditions = array(
      'name' => trim($name),
    );
    if ($vid) {
      $conditions['vid'] = $vid;
    }
    if ($terms = taxonomy_term_load_multiple(array(), $conditions)) {
      $this
        ->add_term(reset($terms));
    }
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Notifications_Subscription_Simple::get_field function In this case we can get fields by type or by position
Notifications_Taxonomy_Term_Subscription::add_term public function Add term object
Notifications_Taxonomy_Term_Subscription::add_term_by_name public function Add term by name (and optional vid)
Notifications_Taxonomy_Term_Subscription::get_name public function Get proper name 1