You are here

class Feed in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-feed/src/Writer/Feed.php \Zend\Feed\Writer\Feed
  2. 8 core/modules/aggregator/src/Entity/Feed.php \Drupal\aggregator\Entity\Feed
  3. 8 vendor/zendframework/zend-feed/src/Reader/Extension/Syndication/Feed.php \Zend\Feed\Reader\Extension\Syndication\Feed
  4. 8 vendor/zendframework/zend-feed/src/Reader/Extension/Atom/Feed.php \Zend\Feed\Reader\Extension\Atom\Feed
  5. 8 vendor/zendframework/zend-feed/src/Reader/Extension/Podcast/Feed.php \Zend\Feed\Reader\Extension\Podcast\Feed
  6. 8 vendor/zendframework/zend-feed/src/Reader/Extension/DublinCore/Feed.php \Zend\Feed\Reader\Extension\DublinCore\Feed
  7. 8 vendor/zendframework/zend-feed/src/Reader/Extension/CreativeCommons/Feed.php \Zend\Feed\Reader\Extension\CreativeCommons\Feed
  8. 8 vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Feed.php \Zend\Feed\Writer\Extension\ITunes\Feed
  9. 8 core/modules/views/src/Plugin/views/display/Feed.php \Drupal\views\Plugin\views\display\Feed
  10. 8 vendor/zendframework/zend-feed/src/Writer/Extension/Atom/Renderer/Feed.php \Zend\Feed\Writer\Extension\Atom\Renderer\Feed
  11. 8 vendor/zendframework/zend-feed/src/Writer/Extension/DublinCore/Renderer/Feed.php \Zend\Feed\Writer\Extension\DublinCore\Renderer\Feed
  12. 8 vendor/zendframework/zend-feed/src/Writer/Extension/ITunes/Renderer/Feed.php \Zend\Feed\Writer\Extension\ITunes\Renderer\Feed
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-feed/src/Reader/Extension/DublinCore/Feed.php \Zend\Feed\Reader\Extension\DublinCore\Feed

Hierarchy

  • class \Zend\Feed\Reader\Extension\DublinCore\Feed extends \Extension\AbstractFeed

Expanded class hierarchy of Feed

19 string references to 'Feed'
aggregator.schema.yml in core/modules/aggregator/config/schema/aggregator.schema.yml
core/modules/aggregator/config/schema/aggregator.schema.yml
core.services.yml in core/core.services.yml
core/core.services.yml
ExtensionPluginManager::validatePlugin in vendor/zendframework/zend-feed/src/Writer/ExtensionPluginManager.php
Validate the plugin
PreviewTest::testPreviewUI in core/modules/views_ui/src/Tests/PreviewTest.php
Tests arguments in the preview form.
views.view.aggregator_rss_feed.yml in core/modules/aggregator/config/optional/views.view.aggregator_rss_feed.yml
core/modules/aggregator/config/optional/views.view.aggregator_rss_feed.yml

... See full list

1 service uses Feed
feed.reader.dublincorefeed in core/core.services.yml
Zend\Feed\Reader\Extension\DublinCore\Feed

File

vendor/zendframework/zend-feed/src/Reader/Extension/DublinCore/Feed.php, line 17

Namespace

Zend\Feed\Reader\Extension\DublinCore
View source
class Feed extends Extension\AbstractFeed {

  /**
   * Get a single author
   *
   * @param  int $index
   * @return string|null
   */
  public function getAuthor($index = 0) {
    $authors = $this
      ->getAuthors();
    if (isset($authors[$index])) {
      return $authors[$index];
    }
    return;
  }

  /**
   * Get an array with feed authors
   *
   * @return array
   */
  public function getAuthors() {
    if (array_key_exists('authors', $this->data)) {
      return $this->data['authors'];
    }
    $authors = [];
    $list = $this
      ->getXpath()
      ->query('//dc11:creator');
    if (!$list->length) {
      $list = $this
        ->getXpath()
        ->query('//dc10:creator');
    }
    if (!$list->length) {
      $list = $this
        ->getXpath()
        ->query('//dc11:publisher');
      if (!$list->length) {
        $list = $this
          ->getXpath()
          ->query('//dc10:publisher');
      }
    }
    if ($list->length) {
      foreach ($list as $author) {
        $authors[] = [
          'name' => $author->nodeValue,
        ];
      }
      $authors = new Collection\Author(Reader\Reader::arrayUnique($authors));
    }
    else {
      $authors = null;
    }
    $this->data['authors'] = $authors;
    return $this->data['authors'];
  }

  /**
   * Get the copyright entry
   *
   * @return string|null
   */
  public function getCopyright() {
    if (array_key_exists('copyright', $this->data)) {
      return $this->data['copyright'];
    }
    $copyright = $this
      ->getXpath()
      ->evaluate('string(' . $this
      ->getXpathPrefix() . '/dc11:rights)');
    if (!$copyright) {
      $copyright = $this
        ->getXpath()
        ->evaluate('string(' . $this
        ->getXpathPrefix() . '/dc10:rights)');
    }
    if (!$copyright) {
      $copyright = null;
    }
    $this->data['copyright'] = $copyright;
    return $this->data['copyright'];
  }

  /**
   * Get the feed description
   *
   * @return string|null
   */
  public function getDescription() {
    if (array_key_exists('description', $this->data)) {
      return $this->data['description'];
    }
    $description = $this
      ->getXpath()
      ->evaluate('string(' . $this
      ->getXpathPrefix() . '/dc11:description)');
    if (!$description) {
      $description = $this
        ->getXpath()
        ->evaluate('string(' . $this
        ->getXpathPrefix() . '/dc10:description)');
    }
    if (!$description) {
      $description = null;
    }
    $this->data['description'] = $description;
    return $this->data['description'];
  }

  /**
   * Get the feed ID
   *
   * @return string|null
   */
  public function getId() {
    if (array_key_exists('id', $this->data)) {
      return $this->data['id'];
    }
    $id = $this
      ->getXpath()
      ->evaluate('string(' . $this
      ->getXpathPrefix() . '/dc11:identifier)');
    if (!$id) {
      $id = $this
        ->getXpath()
        ->evaluate('string(' . $this
        ->getXpathPrefix() . '/dc10:identifier)');
    }
    $this->data['id'] = $id;
    return $this->data['id'];
  }

  /**
   * Get the feed language
   *
   * @return string|null
   */
  public function getLanguage() {
    if (array_key_exists('language', $this->data)) {
      return $this->data['language'];
    }
    $language = $this
      ->getXpath()
      ->evaluate('string(' . $this
      ->getXpathPrefix() . '/dc11:language)');
    if (!$language) {
      $language = $this
        ->getXpath()
        ->evaluate('string(' . $this
        ->getXpathPrefix() . '/dc10:language)');
    }
    if (!$language) {
      $language = null;
    }
    $this->data['language'] = $language;
    return $this->data['language'];
  }

  /**
   * Get the feed title
   *
   * @return string|null
   */
  public function getTitle() {
    if (array_key_exists('title', $this->data)) {
      return $this->data['title'];
    }
    $title = $this
      ->getXpath()
      ->evaluate('string(' . $this
      ->getXpathPrefix() . '/dc11:title)');
    if (!$title) {
      $title = $this
        ->getXpath()
        ->evaluate('string(' . $this
        ->getXpathPrefix() . '/dc10:title)');
    }
    if (!$title) {
      $title = null;
    }
    $this->data['title'] = $title;
    return $this->data['title'];
  }

  /**
   *
   *
   * @return DateTime|null
   */
  public function getDate() {
    if (array_key_exists('date', $this->data)) {
      return $this->data['date'];
    }
    $d = null;
    $date = $this
      ->getXpath()
      ->evaluate('string(' . $this
      ->getXpathPrefix() . '/dc11:date)');
    if (!$date) {
      $date = $this
        ->getXpath()
        ->evaluate('string(' . $this
        ->getXpathPrefix() . '/dc10:date)');
    }
    if ($date) {
      $d = new DateTime($date);
    }
    $this->data['date'] = $d;
    return $this->data['date'];
  }

  /**
   * Get categories (subjects under DC)
   *
   * @return Collection\Category
   */
  public function getCategories() {
    if (array_key_exists('categories', $this->data)) {
      return $this->data['categories'];
    }
    $list = $this
      ->getXpath()
      ->evaluate($this
      ->getXpathPrefix() . '//dc11:subject');
    if (!$list->length) {
      $list = $this
        ->getXpath()
        ->evaluate($this
        ->getXpathPrefix() . '//dc10:subject');
    }
    if ($list->length) {
      $categoryCollection = new Collection\Category();
      foreach ($list as $category) {
        $categoryCollection[] = [
          'term' => $category->nodeValue,
          'scheme' => null,
          'label' => $category->nodeValue,
        ];
      }
    }
    else {
      $categoryCollection = new Collection\Category();
    }
    $this->data['categories'] = $categoryCollection;
    return $this->data['categories'];
  }

  /**
   * Register the default namespaces for the current feed format
   *
   * @return void
   */
  protected function registerNamespaces() {
    $this
      ->getXpath()
      ->registerNamespace('dc10', 'http://purl.org/dc/elements/1.0/');
    $this
      ->getXpath()
      ->registerNamespace('dc11', 'http://purl.org/dc/elements/1.1/');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Feed::getAuthor public function Get a single author
Feed::getAuthors public function Get an array with feed authors
Feed::getCategories public function Get categories (subjects under DC)
Feed::getCopyright public function Get the copyright entry
Feed::getDate public function
Feed::getDescription public function Get the feed description
Feed::getId public function Get the feed ID
Feed::getLanguage public function Get the feed language
Feed::getTitle public function Get the feed title
Feed::registerNamespaces protected function Register the default namespaces for the current feed format