예제 #1
0
 public function testAddAndGetRenderer()
 {
     /** @var VariableRendererInterface $renderer */
     $renderer = $this->prophesize(VariableRendererInterface::class);
     $renderer->getName()->willReturn('test_renderer');
     $this->factory->addRenderer($renderer->reveal());
     $this->assertEquals($this->factory->get('test_renderer'), $renderer->reveal());
 }
 /**
  * @param string $variable
  * @param string $rendererName
  *
  * @return string
  *
  * @throws VariableRendererNotFoundException
  */
 public function render($variable, $rendererName = '')
 {
     $targetRenderer = null;
     if (empty($rendererName)) {
         $targetRenderer = $this->defaultRenderer;
     }
     if (empty($targetRenderer)) {
         throw new VariableRendererNotFoundException('No renderer specified');
     }
     return $this->factory->get(empty($rendererName) ? $this->defaultRenderer : $rendererName)->render($variable);
 }