Esempio n. 1
0
 /**
  *
  * Method used to populate objects with search engine content.
  *
  * @param $json
  * @return SearchResult
  * @throws \Exception
  */
 public function populateObjectFromSearch($json)
 {
     $em = $this->container->get("doctrine")->getManager();
     $content = json_decode($json);
     $results = new SearchResult();
     $results->setTook($content->took);
     $results->setMaxScore($content->hits->max_score);
     $results->setTotal($content->hits->total);
     foreach ($content->hits->hits as $hit) {
         if ($hit->_type == 'leads') {
             $object = new Leads();
         } else {
             throw new \Exception("Type is not available for ORM mapping : " . $hit->_type);
         }
         $results->addResult($object->populateFromSearch($hit->_source, $em));
     }
     return $results;
 }