Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
覆盖Symfony 2.3中的配置文件控制器FOSUserBundle_Symfony_Symfony 2.3 - Fatal编程技术网

覆盖Symfony 2.3中的配置文件控制器FOSUserBundle

覆盖Symfony 2.3中的配置文件控制器FOSUserBundle,symfony,symfony-2.3,Symfony,Symfony 2.3,在这里,我试图覆盖FOSUSerBundle的ProfileController,但在尝试呈现模板时出错,代码如下: namespace XxX\MyBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class MyBundle extends Bundle { public function getParent() { return 'FOSUserBundle'; } } 然后,我尝

在这里,我试图覆盖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');
    }

}
我试过:

return $this->container->get('templating')->renderResponse('MyBundle:Profile:show.html.twig');
但仍然失败

需要帮忙吗


谢谢

FOSUserBundle RegistrationController不扩展SF2提供渲染方法的Symfony\Bundle\FrameworkBundle\Controller\Controller。 它只是实现了ContainerWare接口


调用$this->container->get'templating'->renderResponse时会出现哪个错误?

在这种情况下,我会遇到以下错误:错误:调用未定义的方法XxX\MyBundle\Controller\ProfileController::get In D:\xampp\htdocs\projects\myproject\src\XxX\MyBundle\Controller\ProfileController.php第16行。。。是renderResponseWell的同一行,我修复了错误,当我试图向视图发送变量时,我试图访问实体管理器。谢谢
return $this->container->get('templating')->renderResponse('MyBundle:Profile:show.html.twig');