当前位置: 首页>>代码示例>>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;未经允许,请勿转载。