getParameter() public method

Returns a single named parameter.
public getParameter ( string $param ) : array
$param string
return array
Beispiel #1
0
 /**
  * @param ContentQueryParser $contentQuery
  *
  * @return SearchQueryResultset
  */
 public function __invoke(ContentQueryParser $contentQuery)
 {
     $set = new SearchQueryResultset();
     foreach ($contentQuery->getContentTypes() as $contenttype) {
         $query = $contentQuery->getService('search');
         $repo = $contentQuery->getEntityManager()->getRepository($contenttype);
         $query->setQueryBuilder($repo->createQueryBuilder($contenttype));
         $query->setContentType($contenttype);
         $searchParam = $contentQuery->getParameter('filter');
         $query->setParameters($contentQuery->getParameters());
         $query->setSearch($searchParam);
         $contentQuery->runDirectives($query);
         $result = $repo->queryWith($query);
         if ($result) {
             if (count($result) > 0) {
                 $weighter = $contentQuery->getService('search_weighter');
                 $weighter->setContentType($contenttype);
                 $weighter->setResults($result);
                 $weighter->setSearchWords($query->getSearchWords());
                 $scores = $weighter->weight();
                 $set->add($result, $contenttype, $scores);
             } else {
                 $set->add($result, $contenttype);
             }
         }
     }
     if ($query->getSingleFetchMode()) {
         return $set->current();
     } else {
         return $set;
     }
 }
 public function testDirectiveParsing()
 {
     $app = $this->getApp();
     $qb = new ContentQueryParser($app['storage'], $app['query.select']);
     $qb->setQuery('entries');
     $qb->setParameters(['order' => '-datepublish', 'id' => '!1']);
     $qb->parse();
     $this->assertEquals(['entries'], $qb->getContentTypes());
     $this->assertEquals('select', $qb->getOperation());
     $this->assertEquals('-datepublish', $qb->getDirective('order'));
     $this->assertEquals('!1', $qb->getParameter('id'));
     $this->assertEquals(1, count($qb->getParameters()));
 }
 public function postgresSearch(ContentQueryParser $contentQuery)
 {
     $set = new SearchQueryResultset();
     foreach ($contentQuery->getContentTypes() as $contenttype) {
         $repo = $contentQuery->getEntityManager()->getRepository($contenttype);
         $query = $repo->createQueryBuilder($contenttype);
         $config = $contentQuery->getService('search_config');
         $search = $contentQuery->getParameter('filter');
         $adapter = new PostgresSearch($query, $config, explode(' ', $search));
         $adapter->setContentType($contenttype);
         $result = $repo->findWith($adapter->getQuery());
         $set->add($result, $contenttype);
     }
     return $set;
 }