Example #1
0
 /**
  * 
  * @return \Library\ManagerBundle\Libraries\ResultSet 
  */
 public function getSearchResults()
 {
     $url = $this->_getBaseUrl() . $this->_query->encode();
     $results = array();
     if ($url !== $this->_getBaseUrl()) {
         $cacheFile = __DIR__ . '/../../../../app/cache/' . $this->_config['search_cache']['directory'] . '/' . md5($url);
         if ($this->_isCached($cacheFile)) {
             $results = $this->_getFromCache($cacheFile);
         } else {
             $results = (array) array_unique($this->_getParser()->parse($this->_curl->getPage($url)), SORT_REGULAR);
             $this->_cache($results, $cacheFile);
         }
         $resultSet = new ResultSet(count($results) > 0);
     } else {
         $resultSet = new ResultSet(false);
     }
     return $resultSet->setResults((array) $results);
 }
Example #2
0
 /**
  * @test 
  * @expectedException \Library\ManagerBundle\Exception
  */
 public function setResultsWithInvalidResults()
 {
     $results = array(new Result('a', 'b', 'c', 'd'), new \stdClass(), new \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException());
     $resultSet = new ResultSet(true);
     $resultSet->setResults($results);
 }