Questions tagged «fosuserbundle»

3
访问模板中的登录用户
我正在使用FOSuserbundle来开始用户注册https://github.com/FriendsOfSymfony/FOSUserBundle 我已经注册/登录和注销了。我现在想做的就是获取已登录的用户数据,并将其显示在我网站的每个页面上。就像事物的标题类型中的“ Hi用户名”一样。 似乎在我的app / Resources / views / base.html.twig中嵌入控制器是执行此操作的最佳方法http://symfony.com/doc/current/book/templating.html#embedding-controllers 因此,我编写了控制器来访问用户配置文件数据。我不知道如何在嵌入式控制器中访问FOS方法。因此,从我的Acme / UserBundle / Controller / UserController.php中,我想这样做: public function showAction() { $user = $this->container->get('security.context')->getToken()->getUser(); if (!is_object($user) || !$user instanceof UserInterface) { throw new AccessDeniedException( 'This user does not have access to this section.'); } return $this->container->get('templating') ->renderResponse('FOSUserBundle:Profile:show.html.'.$this->container ->getParameter('fos_user.template.engine'), array('user' => …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.