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


PHP ParserFactory::GetParser方法代碼示例

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


在下文中一共展示了ParserFactory::GetParser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: FetchContentFromChannel

 /**
  * This method will take the information prvided in the
  * instance of a \Swiftriver\Core\ObjectModel\Source object
  * and will make a call to the channel to fetch and content
  * that can be fetched and then parse the content into an array
  * of Swiftriver\Core\ObjectModel\Content items
  *
  * @param \Swiftriver\Core\ObjectModel\Source $source
  * @return Swiftriver\Core\ObjectModel\Content[] $contentItems
  */
 public function FetchContentFromChannel($source)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::SwiftriverSourceParsingService::FetchContentFromChannel [Method invoked]", \PEAR_LOG_DEBUG);
     if (!isset($source) || $source == null) {
         $logger->log("Core::Modules::SiSPS::SwiftriverSourceParsingService::FetchContentFromChannel [The channel object param is null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Modules::SiSPS::SwiftriverSourceParsingService::FetchContentFromChannel [Method finished]", \PEAR_LOG_DEBUG);
         return;
     }
     //get the type of the channel
     $channelType = $source->type;
     $logger->log("Core::Modules::SiSPS::SwiftriverSourceParsingService::FetchContentFromChannel [Channel type is {$channelType}]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::SwiftriverSourceParsingService::FetchContentFromChannel [START: Constructed parser from factory]", \PEAR_LOG_DEBUG);
     //Get a Parser from the ParserFactory based on the channel type
     $parser = ParserFactory::GetParser($channelType);
     $logger->log("Core::Modules::SiSPS::SwiftriverSourceParsingService::FetchContentFromChannel [END: Constructed parser from factory]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::SwiftriverSourceParsingService::FetchContentFromChannel [START: parser->GetAndParse]", \PEAR_LOG_DEBUG);
     try {
         //Get and parse all avaliable content items from the parser
         $contentItems = $parser->GetAndParse($source);
     } catch (\Exception $e) {
         $logger->log("Core::Modules::SiSPS::SwiftriverSourceParsingService::FetchContentFromChannel [{$e}]", \PEAR_LOG_ERR);
         $logger->log("Core::Modules::SiSPS::SwiftriverSourceParsingService::FetchContentFromChannel [Method finished]", \PEAR_LOG_DEBUG);
         return array();
     }
     $logger->log("Core::Modules::SiSPS::SwiftriverSourceParsingService::FetchContentFromChannel [END: parser->GetAndParse]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::SwiftriverSourceParsingService::FetchContentFromChannel [Method finished]", \PEAR_LOG_DEBUG);
     //Return the content items
     return $contentItems;
 }
開發者ID:unthinkingly,項目名稱:Swiftriver,代碼行數:40,代碼來源:SwiftriverSourceParsingService.php

示例2: FetchContentFromChannel

 /**
  * This method will take the information prvided in the
  * instance of a Swiftriver\Core\ObjectModel\Channel object
  * and will make a call to the channel to fetch and content
  * that can be fetched and then parse the content into an array
  * of Swiftriver\Core\ObjectModel\Content items
  *
  * @param Swiftriver\Core\ObjectModel\Channel $channel
  * @return Swiftriver\Core\ObjectModel\Content[] $contentItems
  */
 public function FetchContentFromChannel($channel)
 {
     //get the type of the channel
     $channelType = $channel->GetType();
     //Get a Parser from the ParserFactory based on the channel type
     $factory = ParserFactory::GetParser($channelType);
     //Extract the parameters from the channel object
     $parameters = $channel->GetParameters();
     //Get and parse all avaliable content items from the parser
     $contentItems = $factory->GetAndParse($parameters);
     //Return the content items
     return $contentItems;
 }
開發者ID:surflightroy,項目名稱:SwiftriverCore,代碼行數:23,代碼來源:SwiftriverSourceParsingService.php


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