当前位置: 首页>>代码示例>>PHP>>正文


PHP Reader::setExtensionManager方法代码示例

本文整理汇总了PHP中Zend\Feed\Reader\Reader::setExtensionManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Reader::setExtensionManager方法的具体用法?PHP Reader::setExtensionManager怎么用?PHP Reader::setExtensionManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Feed\Reader\Reader的用法示例。


在下文中一共展示了Reader::setExtensionManager方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isFeed

 /**
  * Returns if the provided $content_type is a feed.
  *
  * @param string $document
  *   The actual HTML or XML document from the HTTP request.
  *
  * @return bool
  *   Returns true if this is a parsable feed, false if not.
  */
 public static function isFeed($data)
 {
     Reader::setExtensionManager(\Drupal::service('feed.bridge.reader'));
     try {
         $feed_type = Reader::detectType($data);
     } catch (\Exception $e) {
         return FALSE;
     }
     return $feed_type != Reader::TYPE_ANY;
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:19,代码来源:Feed.php

示例2: __invoke

 public function __invoke($services)
 {
     $http = $services->get('http');
     FeedReader::setHttpClient($http);
     FeedReader::setExtensionManager($this->createExtensionManager());
     $config = $services->get('Config');
     $config = $config['github'];
     $reader = new AtomReader($config['user']);
     $reader->setLimit($config['limit']);
     return $reader;
 }
开发者ID:bcremer,项目名称:mwop.net,代码行数:11,代码来源:AtomReaderFactory.php

示例3: setUp

 function setUp()
 {
     parent::setUp();
     // Do not delete old aggregator items during these tests, since our sample
     // feeds have hardcoded dates in them (which may be expired when this test
     // is run).
     $this->container->get('config.factory')->get('aggregator.settings')->set('items.expire', AGGREGATOR_CLEAR_NEVER)->save();
     // Reset any reader cache between tests.
     Reader::reset();
     // Set our bridge extension manager to Zend Feed.
     $bridge = $this->container->get('feed.bridge.reader');
     Reader::setExtensionManager($bridge);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:13,代码来源:FeedParserTest.php

示例4: __invoke

 public function __invoke(ContainerInterface $container) : AtomReader
 {
     $http = $container->get(FeedReaderHttpClientInterface::class);
     FeedReader::setHttpClient($http);
     FeedReader::setExtensionManager(new StandaloneExtensionManager());
     $config = $container->get('config');
     $config = $config['github'];
     $reader = new AtomReader($config['user']);
     $reader->setLimit($config['limit']);
     $reader->addFilter(function ($entry) {
         if (false !== strpos($entry->getLink(), 'weierophinney/mwop.net')) {
             return false;
         }
         return true;
     });
     return $reader;
 }
开发者ID:vrkansagara,项目名称:mwop.net,代码行数:17,代码来源:AtomReaderFactory.php

示例5: parse

 /**
  * {@inheritdoc}
  */
 public function parse(FeedInterface $feed)
 {
     // Set our bridge extension manager to Zend Feed.
     Reader::setExtensionManager(\Drupal::service('feed.bridge.reader'));
     try {
         $channel = Reader::importString($feed->source_string);
     } catch (ExceptionInterface $e) {
         watchdog_exception('aggregator', $e);
         drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->label(), '%error' => $e->getMessage())), 'error');
         return FALSE;
     }
     $feed->setWebsiteUrl($channel->getLink());
     $feed->setDescription($channel->getDescription());
     if ($image = $channel->getImage()) {
         $feed->setImage($image['uri']);
     }
     // Initialize items array.
     $feed->items = array();
     foreach ($channel as $item) {
         // Reset the parsed item.
         $parsed_item = array();
         // Move the values to an array as expected by processors.
         $parsed_item['title'] = $item->getTitle();
         $parsed_item['guid'] = $item->getId();
         $parsed_item['link'] = $item->getLink();
         $parsed_item['description'] = $item->getDescription();
         $parsed_item['author'] = '';
         if ($author = $item->getAuthor()) {
             $parsed_item['author'] = $author['name'];
         }
         $parsed_item['timestamp'] = '';
         if ($date = $item->getDateModified()) {
             $parsed_item['timestamp'] = $date->getTimestamp();
         }
         // Store on $feed object. This is where processors will look for parsed items.
         $feed->items[] = $parsed_item;
     }
     return TRUE;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:42,代码来源:DefaultParser.php

示例6: parse

 /**
  * {@inheritdoc}
  */
 public function parse(FeedInterface $feed, FetcherResultInterface $fetcher_result, StateInterface $state)
 {
     $result = new ParserResult();
     Reader::setExtensionManager(\Drupal::service('feed.bridge.reader'));
     Reader::registerExtension('GeoRSS');
     $raw = $fetcher_result->getRaw();
     if (!strlen(trim($raw))) {
         throw new EmptyFeedException();
     }
     try {
         $channel = Reader::importString($raw);
     } catch (ExceptionInterface $e) {
         $args = ['%site' => $feed->label(), '%error' => trim($e->getMessage())];
         throw new \RuntimeException($this->t('The feed from %site seems to be broken because of error "%error".', $args));
     }
     foreach ($channel as $delta => $entry) {
         $item = new SyndicationItem();
         // Move the values to an array as expected by processors.
         $item->set('title', $entry->getTitle())->set('guid', $entry->getId())->set('url', $entry->getLink())->set('guid', $entry->getId())->set('url', $entry->getLink())->set('description', $entry->getDescription())->set('tags', $entry->getCategories()->getValues())->set('feed_title', $channel->getTitle())->set('feed_description', $channel->getDescription())->set('feed_url', $channel->getLink());
         if ($image = $channel->getImage()) {
             $item->set('feed_image_uri', $image['uri']);
         }
         if ($enclosure = $entry->getEnclosure()) {
             $item->set('enclosures', [rawurldecode($enclosure->url)]);
         }
         if ($author = $entry->getAuthor()) {
             $author += ['name' => '', 'email' => ''];
             $item->set('author_name', $author['name'])->set('author_email', $author['email']);
         }
         if ($date = $entry->getDateModified()) {
             $item->set('timestamp', $date->getTimestamp());
         }
         if ($point = $entry->getGeoPoint()) {
             $item->set('georss_lat', $point['lat'])->set('georss_lon', $point['lon']);
         }
         $result->addItem($item);
     }
     return $result;
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:42,代码来源:SyndicationParser.php

示例7: parse

 /**
  * {@inheritdoc}
  */
 public function parse(FeedInterface $feed, FetcherResultInterface $fetcher_result)
 {
     $result = new ParserResult();
     Reader::setExtensionManager(\Drupal::service('feed.bridge.reader'));
     try {
         $channel = Reader::importString($fetcher_result->getRaw());
     } catch (ExceptionInterface $e) {
         watchdog_exception('feeds', $e);
         drupal_set_message($this->t('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->label(), '%error' => $e->getMessage())), 'error');
         return $result;
     }
     $result->title = $channel->getTitle();
     $result->description = $channel->getDescription();
     $result->link = $channel->getLink();
     foreach ($channel as $item) {
         // Reset the parsed item.
         $parsed_item = array();
         // Move the values to an array as expected by processors.
         $parsed_item['title'] = $item->getTitle();
         $parsed_item['guid'] = $item->getId();
         $parsed_item['url'] = $item->getLink();
         $parsed_item['description'] = $item->getDescription();
         if ($enclosure = $item->getEnclosure()) {
             $parsed_item['enclosures'][] = urldecode($enclosure->url);
         }
         if ($author = $item->getAuthor()) {
             $parsed_item['author_name'] = $author['name'];
         }
         if ($date = $item->getDateModified()) {
             $parsed_item['timestamp'] = $date->getTimestamp();
         }
         $parsed_item['tags'] = $item->getCategories()->getValues();
         $result->items[] = $parsed_item;
     }
     return $result;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:39,代码来源:SyndicationParser.php


注:本文中的Zend\Feed\Reader\Reader::setExtensionManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。