Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function render($data, array $options)
 {
     if (($resource = $this->getValue($data, $options)) === null) {
         return;
     }
     if (!isset($this->cache[$hash = spl_object_hash($options['grid']) . ':' . spl_object_hash($options['column'])])) {
         $this->cache[$hash] = new Column($options['resource_path'], null, $options['type'], $options['options']);
     }
     return $this->renderer->render($options['grid'], $this->cache[$hash], $resource);
 }
Esempio n. 2
0
 /**
  * @dataProvider renderProvider
  */
 public function testRenderColumn($gridTemplate = null, $rendererTemplate = null)
 {
     $template = 'column';
     if ($rendererTemplate !== null) {
         $this->renderer = new Renderer($this->twig, $this->actionRenderer, $this->columnRenderer, $this->sorterRenderer, [$template => $rendererTemplate]);
     }
     $view = $this->createGridViewMock();
     $view->expects($this->once())->method('getDefinition')->will($this->returnValue($grid = $this->createGridMock()));
     $grid->expects($this->once())->method('hasOption')->with($this->identicalTo($option = $template . '_template'))->will($this->returnValue($gridTemplate !== null));
     $grid->expects($gridTemplate !== null ? $this->once() : $this->never())->method('getOption')->with($this->identicalTo($option))->will($this->returnValue($gridTemplate));
     $this->columnRenderer->expects($this->once())->method('render')->with($this->identicalTo($view), $this->identicalTo($column = $this->createColumnMock()), $this->identicalTo($data = new \stdClass()))->will($this->returnValue($value = 'value'));
     $this->twig->expects($this->once())->method('render')->with($this->identicalTo($gridTemplate ?: ($rendererTemplate ?: '@LugGrid/' . $template . '.html.twig')), $this->identicalTo(['column' => $column, 'data' => $data, 'value' => $value, 'grid' => $view]))->will($this->returnValue($result = 'result'));
     $this->assertSame($result, $this->renderer->renderColumn($view, $column, $data));
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function renderColumn(GridViewInterface $grid, ColumnInterface $column, $data)
 {
     return $this->doRender($grid, 'column', ['column' => $column, 'data' => $data, 'value' => $this->columnRenderer->render($grid, $column, $data)]);
 }
Esempio n. 4
0
 public function testRenderWithNull()
 {
     $this->propertyAccessor->expects($this->once())->method('getValue')->with($this->identicalTo($data = new \stdClass()), $this->identicalTo($path = 'path_value'))->will($this->returnValue(null));
     $this->renderer->expects($this->never())->method('render');
     $this->assertNull($this->type->render($data, ['path' => $path]));
 }