Exemplo n.º 1
0
 /**
  * @param ContentQueryParser $contentQuery
  *
  * @return QueryResultset
  */
 public function __invoke(ContentQueryParser $contentQuery)
 {
     $set = new QueryResultset();
     /** @var SelectQuery $query */
     $query = $contentQuery->getService('select');
     foreach ($contentQuery->getContentTypes() as $contentType) {
         $repo = $contentQuery->getEntityManager()->getRepository($contentType);
         $query->setQueryBuilder($repo->createQueryBuilder($contentType));
         $query->setContentType($contentType);
         /** Run the parameters through the whitelister. If we get a false back from this method it's because there
          * is no need to continue with the query.
          */
         $params = $this->whitelistParameters($contentQuery->getParameters(), $repo);
         if (!$params && count($contentQuery->getParameters())) {
             continue;
         }
         /** Continue and run the query add the results to the set */
         $query->setParameters($params);
         $contentQuery->runDirectives($query);
         $result = $repo->queryWith($query);
         if ($result) {
             $set->add($result, $contentType);
         }
     }
     if ($query->getSingleFetchMode()) {
         return $set->current();
     } else {
         return $set;
     }
 }
Exemplo n.º 2
0
 public function testNoLabelFetch()
 {
     $array1 = ['test1', 'test2', 'test3'];
     $array2 = ['test4', 'test5', 'test6'];
     $set = new QueryResultset();
     $set->add($array1);
     $set->add($array2);
     $this->assertEquals(6, count($set->get()));
 }
Exemplo n.º 3
0
 /**
  * @param ContentQueryParser $contentQuery
  *
  * @return QueryResultset
  */
 public function __invoke(ContentQueryParser $contentQuery)
 {
     $set = new QueryResultset();
     foreach ($contentQuery->getContentTypes() as $contenttype) {
         $query = $contentQuery->getService('select');
         $repo = $contentQuery->getEntityManager()->getRepository($contenttype);
         $query->setQueryBuilder($repo->createQueryBuilder($contenttype));
         $query->setContentType($contenttype);
         $query->setParameters($contentQuery->getParameters());
         $contentQuery->runDirectives($query);
         $result = $repo->queryWith($query);
         if ($result) {
             $set->add($result, $contenttype);
         }
     }
     if ($query->getSingleFetchMode()) {
         return $set->current();
     } else {
         return $set;
     }
 }