Render Twig in Bundle

New topics about Symfony 2 should go here

Moderators: dcobalt, tiagojsag

Render Twig in Bundle

Postby Zack » Wed Jul 11, 2012 11:48 am

Hi,
is there a way to render a template in a bundle? I tryed this:
Code: Select all
<?php

namespace Aranox\ContactBundle;

use Aranox\CoreBundle\WidgetInterface;
use \Symfony\Component\HttpKernel\Bundle\Bundle;

class AranoxContactBundle extends Bundle implements WidgetInterface
{
    protected $container;
    public function __constructor($container)
    {
        $this->container = $container;
    }

    public function render()
    {
        return $this->container->render("AranoxContactBundle:Widget:content.html.twig");
    }
}



Edit: Sorry forgot most important: container is always null, the question is, how to get the render method.

Edit2: Ok, I found help at irc. Thanks :)
User avatar
Zack
Junior Member
 
Posts: 12
Joined: Sun Oct 24, 2010 8:46 pm
Location: Germany

Return to General Symfony 2 discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron