function it_uses_twig_to_render_the_action(\Twig_Environment $twig, GridViewInterface $gridView, Action $action) { $action->getType()->willReturn('link'); $action->getOptions()->willReturn([]); $twig->render('SyliusGridBundle:Action:_link.html.twig', ['grid' => $gridView, 'action' => $action, 'data' => null])->willReturn('<a href="#">Action!</a>'); $this->renderAction($gridView, $action)->shouldReturn('<a href="#">Action!</a>'); }
/** * {@inheritdoc} */ public function renderAction(GridViewInterface $gridView, Action $action, $data = null) { $type = $action->getType(); if (!isset($this->actionTemplates[$type])) { throw new \InvalidArgumentException(sprintf('Missing template for action type "%s".', $type)); } $options = $this->optionsParser->parseOptions($action->getOptions(), $gridView->getRequestConfiguration()->getRequest(), $data); return $this->twig->render($this->actionTemplates[$type], ['grid' => $gridView, 'action' => $action, 'data' => $data, 'options' => $options]); }
function it_uses_twig_to_render_the_action(\Twig_Environment $twig, OptionsParserInterface $optionsParser, ResourceGridView $gridView, Action $action, RequestConfiguration $requestConfiguration, Request $request) { $action->getType()->willReturn('link'); $action->getOptions()->willReturn([]); $gridView->getRequestConfiguration()->willReturn($requestConfiguration); $requestConfiguration->getRequest()->willReturn($request); $optionsParser->parseOptions([], $request, null)->shouldBeCalled(); $twig->render('SyliusGridBundle:Action:_link.html.twig', ['grid' => $gridView, 'action' => $action, 'data' => null, 'options' => []])->willReturn('<a href="#">Action!</a>'); $this->renderAction($gridView, $action)->shouldReturn('<a href="#">Action!</a>'); }