當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Reader::detectType方法代碼示例

本文整理匯總了PHP中Zend\Feed\Reader\Reader::detectType方法的典型用法代碼示例。如果您正苦於以下問題:PHP Reader::detectType方法的具體用法?PHP Reader::detectType怎麽用?PHP Reader::detectType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Feed\Reader\Reader的用法示例。


在下文中一共展示了Reader::detectType方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: __construct

 /**
  * Constructor
  *
  * @param  DOMElement $entry
  * @param  int $entryKey
  * @param  null|string $type
  */
 public function __construct(DOMElement $entry, $entryKey, $type = null)
 {
     $this->entry = $entry;
     $this->entryKey = $entryKey;
     $this->domDocument = $entry->ownerDocument;
     if ($type !== null) {
         $this->data['type'] = $type;
     } else {
         $this->data['type'] = Reader::detectType($entry);
     }
     $this->_loadExtensions();
 }
開發者ID:karnurik,項目名稱:zf2-turtorial,代碼行數:19,代碼來源:AbstractEntry.php

示例3: __construct

 /**
  * Constructor
  *
  * @param DomDocument $domDocument The DOM object for the feed's XML
  * @param string $type Feed type
  */
 public function __construct(DOMDocument $domDocument, $type = null)
 {
     $this->domDocument = $domDocument;
     $this->xpath = new DOMXPath($this->domDocument);
     if ($type !== null) {
         $this->data['type'] = $type;
     } else {
         $this->data['type'] = Reader::detectType($this->domDocument);
     }
     $this->registerNamespaces();
     $this->indexEntries();
     $this->loadExtensions();
 }
開發者ID:tillk,項目名稱:vufind,代碼行數:19,代碼來源:AbstractFeed.php

示例4: __construct

 /**
  * Constructor
  *
  * @param  Zend_Feed_Abstract $feed The source Zend_Feed object
  * @param  string $type Feed type
  * @return void
  */
 public function __construct(\DomDocument $dom, $type = null, \DOMXPath $xpath = null)
 {
     $this->_domDocument = $dom;
     if ($type !== null) {
         $this->_data['type'] = $type;
     } else {
         $this->_data['type'] = Reader\Reader::detectType($dom);
     }
     if ($xpath !== null) {
         $this->_xpath = $xpath;
     } else {
         $this->_xpath = new \DOMXPath($this->_domDocument);
     }
     $this->_registerNamespaces();
 }
開發者ID:rexmac,項目名稱:zf2,代碼行數:22,代碼來源:AbstractFeed.php

示例5: __construct

 /**
  * Constructor
  *
  * @param  Zend_Feed_Entry_Abstract $entry
  * @param  int $entryKey
  * @param  string $type
  * @return void
  */
 public function __construct(\DOMElement $entry, $entryKey, $type = null)
 {
     $this->_entry = $entry;
     $this->_entryKey = $entryKey;
     $this->_domDocument = $entry->ownerDocument;
     if ($type !== null) {
         $this->_data['type'] = $type;
     } else {
         $this->_data['type'] = Reader\Reader::detectType($entry->ownerDocument, true);
     }
     // set the XPath query prefix for the entry being queried
     if ($this->getType() == Reader\Reader::TYPE_RSS_10 || $this->getType() == Reader\Reader::TYPE_RSS_090) {
         $this->setXpathPrefix('//rss:item[' . ($this->_entryKey + 1) . ']');
     } elseif ($this->getType() == Reader\Reader::TYPE_ATOM_10 || $this->getType() == Reader\Reader::TYPE_ATOM_03) {
         $this->setXpathPrefix('//atom:entry[' . ($this->_entryKey + 1) . ']');
     } else {
         $this->setXpathPrefix('//item[' . ($this->_entryKey + 1) . ']');
     }
 }
開發者ID:brikou,項目名稱:zend_feed,代碼行數:27,代碼來源:AbstractEntry.php

示例6:

 /**
  * @group ZF-9723
  */
 public function testDetectsTypeFromStringOrToRemindPaddyAboutForgettingATestWhichLetsAStupidTypoSurviveUnnoticedForMonths()
 {
     $feed = '<?xml version="1.0" encoding="utf-8" ?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/"><channel></channel></rdf:RDF>';
     $type = Reader\Reader::detectType($feed);
     $this->assertEquals(Reader\Reader::TYPE_RSS_10, $type);
 }
開發者ID:bradley-holt,項目名稱:zf2,代碼行數:9,代碼來源:ReaderTest.php

示例7: getType

 /**
  * Get the entry type
  *
  * @return string
  */
 public function getType()
 {
     $type = $this->data['type'];
     if ($type === null) {
         $type = Reader\Reader::detectType($this->getEntryElement(), true);
         $this->setType($type);
     }
     return $type;
 }
開發者ID:ninahuanca,項目名稱:zf2,代碼行數:14,代碼來源:AbstractEntry.php

示例8: getType

 /**
  * Get the feed type
  *
  * If null, it will attempt to autodetect the type.
  *
  * @return string
  */
 public function getType()
 {
     $type = $this->data['type'];
     if (null === $type) {
         $type = Reader\Reader::detectType($this->getDomDocument());
         $this->setType($type);
     }
     return $type;
 }
開發者ID:tejdeeps,項目名稱:tejcs.com,代碼行數:16,代碼來源:AbstractFeed.php

示例9: testImportRemoteFeedMethodPerformsAsExpected

 public function testImportRemoteFeedMethodPerformsAsExpected()
 {
     $uri = 'http://example.com/feeds/reader.xml';
     $feedContents = file_get_contents($this->feedSamplePath . '/Reader/rss20.xml');
     $response = $this->getMock('Zend\\Feed\\Reader\\Http\\ResponseInterface', array('getStatusCode', 'getBody'));
     $response->expects($this->once())->method('getStatusCode')->will($this->returnValue(200));
     $response->expects($this->once())->method('getBody')->will($this->returnValue($feedContents));
     $client = $this->getMock('Zend\\Feed\\Reader\\Http\\ClientInterface', array('get'));
     $client->expects($this->once())->method('get')->with($this->equalTo($uri))->will($this->returnValue($response));
     $feed = Reader\Reader::importRemoteFeed($uri, $client);
     $this->assertInstanceOf('Zend\\Feed\\Reader\\Feed\\FeedInterface', $feed);
     $type = Reader\Reader::detectType($feed);
     $this->assertEquals(Reader\Reader::TYPE_RSS_20, $type);
 }
開發者ID:rajanlamic,項目名稱:IntTest,代碼行數:14,代碼來源:ReaderTest.php


注:本文中的Zend\Feed\Reader\Reader::detectType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。