【发布时间】:2014-05-09 01:54:42
【问题描述】:
那里,我正在尝试覆盖 FOSUSerBundle 的 ProfileController,但尝试渲染模板时出错,这是代码:
namespace XxX\MyBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class MyBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
}
然后,我尝试覆盖控制器:
<?php
namespace XxX\MyBundle\Controller;
use FOS\UserBundle\Controller\RegistrationController as BaseController;
class ProfileController extends BaseController
{
public function myAction()
{
$userManager = $this->container->get('fos_user.user_manager');
$user = $userManager->findUserByUsername($this->container->get('security.context')
->getToken()
->getUser());
return $this->render('MyBundle:Profile:show.html.twig');
}
}
我收到此错误:
Error: Call to undefined method XxX\MyBundle\Controller\ProfileController::render() in D:\xampp\htdocs\projects\alopatria\src\Jaguar\AloBundle\Controller\ProfileController.php line 16
我试过了:
return $this->container->get('templating')->renderResponse('MyBundle:Profile:show.html.twig');
但还是失败了……
有什么帮助吗?
谢谢!
【问题讨论】:
标签: symfony symfony-2.3