/** * {@inheritdoc} * * @throws \InvalidArgumentException If the report subject does not have a renderer. */ public function render(ReportInterface $subject, Data $data) { if (null === ($type = $subject->getRenderer())) { throw new \InvalidArgumentException('Cannot render data for ReportInterface instance without renderer defined.'); } $renderer = $this->registry->get($type); return $renderer->render($subject, $data); }
function it_adds_configuration_fields_in_pre_set_data($factory, ReportInterface $report, FormEvent $event, Form $form, Form $field) { $report->getRenderer()->willReturn('test_renderer'); $report->getRendererConfiguration()->willReturn([]); $event->getData()->willReturn($report); $event->getForm()->willReturn($form); $factory->createNamed('rendererConfiguration', 'sylius_renderer_test_type', Argument::cetera())->willReturn($field); $form->add($field)->shouldBeCalled(); $this->preSetData($event); }
public function it_should_throw_exception_if_report_has_no_renderer_defined(ReportInterface $subject, Data $data) { $subject->getRenderer()->willReturn(null); $this->shouldThrow(new \InvalidArgumentException('Cannot render data for ReportInterface instance without renderer defined.'))->duringRender($subject, $data); }