/** * 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; }
/** * 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; }