Ejemplo n.º 1
0
 public function testDataSourceWithOptions()
 {
     $options = $sortedOptions = ['foo' => 'bar', 'baz' => 'bat'];
     ksort($sortedOptions);
     $this->dataSourceBuilder->expects($this->once())->method('createDataSource')->with($this->identicalTo($sortedOptions))->will($this->returnValue($dataSource = $this->createDataSourceMock()));
     $this->assertSame($dataSource, $this->view->getDataSource($options));
     $this->assertSame($dataSource, $this->view->getDataSource($sortedOptions));
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getDataSource(array $options = [])
 {
     ksort($options);
     return isset($this->cache[$hash = sha1(json_encode($options))]) ? $this->cache[$hash] : ($this->cache[$hash] = $this->dataSourceBuilder->createDataSource($options));
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function slice(DataSourceBuilderInterface $builder, GridInterface $grid, array $slicing)
 {
     $limit = isset($slicing['limit']) ? $slicing['limit'] : ($grid->hasOption('limit') ? $grid->getOption('limit') : 10);
     $page = isset($slicing['page']) ? $slicing['page'] : ($grid->hasOption('page') ? $grid->getOption('page') : 1);
     $builder->setLimit($limit)->setPage($page);
 }