Contao\CoreBundle\Controller\InsertTagsController::renderAction PHP Method

renderAction() public method

Renders an insert tag.
public renderAction ( string $insertTag ) : Response
$insertTag string
return Symfony\Component\HttpFoundation\Response
    public function renderAction($insertTag)
    {
        $this->framework->initialize();
        /** @var InsertTags $it */
        $it = $this->framework->createInstance('Contao\\InsertTags');
        // Never cache these responses
        return (new Response($it->replace($insertTag, false)))->setPrivate();
    }

Usage Example

 /**
  * Tests the renderNonCacheableInsertTag() action.
  */
 public function testRenderNonCacheableInsertTag()
 {
     $insertTagAdapter = $this->getMockBuilder('Contao\\CoreBundle\\Framework\\Adapter')->setMethods(['replace'])->disableOriginalConstructor()->getMock();
     $insertTagAdapter->expects($this->any())->method('replace')->willReturn('3858f62230ac3c915f300c664312c63f');
     $controller = new InsertTagsController($this->mockFramework($insertTagAdapter));
     $response = $controller->renderAction('{{request_token}}');
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
     $this->assertTrue($response->headers->hasCacheControlDirective('private'));
     $this->assertSame('3858f62230ac3c915f300c664312c63f', $response->getContent());
 }
InsertTagsController