Symfony FOSuserBundle超控控制器

Symfony FOSuserBundle超控控制器,symfony,fosuserbundle,Symfony,Fosuserbundle,在Symfony 3.4中,向设置twig模板概要文件/show_content.html.twig传递更多变量的正确方法是什么 我基本上想重写和传递的不仅仅是用户变量ti twig模板 我试着跟着这个。它似乎不再适用于Symfony 3.4,我这样做的方式可能会有更好的方法,只需创建一个新的控制器,其中包含一条到原始“显示路线”的路线,以及我想要传递的变量。下面是一个带有额外变量的showAction示例: namespace App\Controller; use FOS\UserBund

在Symfony 3.4中,向设置twig模板概要文件/show_content.html.twig传递更多变量的正确方法是什么

我基本上想重写和传递的不仅仅是用户变量ti twig模板


我试着跟着这个。它似乎不再适用于Symfony 3.4,我这样做的方式可能会有更好的方法,只需创建一个新的控制器,其中包含一条到原始“显示路线”的路线,以及我想要传递的变量。下面是一个带有额外变量的showAction示例:

namespace App\Controller;

use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

class ProfileController extends Controller
{
    /**
    * Show the user.
    * @Route("/profile/show")
    */
    public function showAction()
    {
    $user = $this->getUser();
    if (!is_object($user) || !$user instanceof UserInterface) {
        throw new AccessDeniedException('This user does not have access to this section.');
    }

    $address = $this->getUser()->renderAddress(); // here is get my variable

    return $this->render('@FOSUser/Profile/show.html.twig', array(
        'user' => $user,
        'rendered_address' => $address // here is pass my variable
    ));
    }
}