Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function handle(GridInterface $grid, array $filters = [], array $sorting = [], array $slicing = [])
 {
     $repository = $this->repositoryRegistry[$grid->getResource()->getName()];
     $dataSourceBuilder = $repository->createDataSourceBuilder($grid->getOptions());
     $this->filterer->filter($dataSourceBuilder, $grid, $filters);
     $this->sorter->sort($dataSourceBuilder, $grid, $sorting);
     $this->slicer->slice($dataSourceBuilder, $grid, $slicing);
     return $this->gridViewFactory->create($grid, $dataSourceBuilder);
 }
Beispiel #2
0
 public function testHandle()
 {
     $grid = $this->createGridMock();
     $grid->expects($this->once())->method('getResource')->will($this->returnValue($resource = $this->createResourceMock()));
     $grid->expects($this->once())->method('getOptions')->will($this->returnValue($options = ['foo' => 'bar']));
     $resource->expects($this->once())->method('getName')->will($this->returnValue($name = 'name'));
     $this->repositoryRegistry->expects($this->once())->method('offsetGet')->with($this->identicalTo($name))->will($this->returnValue($repository = $this->createRepositoryMock()));
     $repository->expects($this->once())->method('createDataSourceBuilder')->with($this->identicalTo($options))->will($this->returnValue($builder = $this->createDataSourceBuilderMock()));
     $this->filterer->expects($this->once())->method('filter')->with($this->identicalTo($builder), $this->identicalTo($grid), $this->identicalTo($filters = ['filter']));
     $this->sorter->expects($this->once())->method('sort')->with($this->identicalTo($builder), $this->identicalTo($grid), $this->identicalTo($sorting = ['sort']));
     $this->slicer->expects($this->once())->method('slice')->with($this->identicalTo($builder), $this->identicalTo($grid), $this->identicalTo($slicing = ['slice']));
     $this->gridViewFactory->expects($this->once())->method('create')->with($this->identicalTo($grid), $this->identicalTo($builder))->will($this->returnValue($view = $this->createGridViewMock()));
     $this->assertSame($view, $this->handler->handle($grid, $filters, $sorting, $slicing));
 }