コード例 #1
0
 public function testResolveHints()
 {
     $query = $this->getQuery();
     $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, ['another_walker_class']);
     $query->setHint('test_output', true);
     $this->queryHintResolver->addOutputWalker('test_output', 'Test\\OutputWalker', null, 'HINT_1');
     $walkerHintProvider = $this->getMock('Oro\\Bundle\\EntityBundle\\ORM\\QueryWalkerHintProviderInterface');
     $this->queryHintResolver->addTreeWalker('test_tree', 'Test\\TreeWalker', $walkerHintProvider, 'HINT_2');
     $walkerHintProvider->expects($this->once())->method('getHints')->with('hint_2_param')->willReturn(['test.tree_walker.hint' => 'val1']);
     $this->queryHintResolver->resolveHints($query, [['name' => 'HINT_2', 'value' => 'hint_2_param'], 'HINT_REFRESH', ['name' => Query::HINT_CUSTOM_TREE_WALKERS, 'value' => 'walker_class']]);
     $this->assertEquals(['test_output' => true, 'test_tree' => 'hint_2_param', Query::HINT_CUSTOM_TREE_WALKERS => ['another_walker_class', 'walker_class', 'Test\\TreeWalker'], Query::HINT_REFRESH => true, Query::HINT_CUSTOM_OUTPUT_WALKER => 'Test\\OutputWalker', 'test.tree_walker.hint' => 'val1'], $query->getHints());
 }
コード例 #2
0
 /**
  * @return ResultRecordInterface[]
  */
 public function getResults()
 {
     $query = $this->qb->getQuery();
     $this->queryHintResolver->resolveHints($query, null !== $this->queryHints ? $this->queryHints : []);
     $event = new OrmResultBefore($this->datagrid, $query);
     $this->eventDispatcher->dispatch(OrmResultBefore::NAME, $event);
     $results = $event->getQuery()->execute();
     $rows = [];
     foreach ($results as $result) {
         $rows[] = new ResultRecord($result);
     }
     $event = new OrmResultAfter($this->datagrid, $rows);
     $this->eventDispatcher->dispatch(OrmResultAfter::NAME, $event);
     return $event->getRecords();
 }
 /**
  * @return ResultRecordInterface[]
  */
 public function getResults()
 {
     $audit = [];
     $rows = [];
     /** @var $qb QueryBuilder $query */
     foreach ($this->getQueryBuilders() as $qb) {
         $query = $qb->getQuery();
         $this->queryHintResolver->resolveHints($query, null !== $this->queryHints ? $this->queryHints : []);
         $beforeEvent = new OrmResultBefore($this->grid, $query);
         $this->dispatcher->dispatch(OrmResultBefore::NAME, $beforeEvent);
         $result = $beforeEvent->getQuery()->execute();
         $audit = array_merge($audit, $result);
         unset($result, $query, $beforeEvent);
     }
     $this->applySorting($audit);
     foreach ($audit as $item) {
         $rows[] = new ResultRecord($item);
     }
     $this->applyPagination($rows);
     $event = new OrmResultAfter($this->grid, $rows);
     $this->dispatcher->dispatch(OrmResultAfter::NAME, $event);
     $records = $event->getRecords();
     return $records;
 }