Symfony Flex:覆盖FOSUser登录表单

问题描述 投票:0回答:2

我读了两种方法来覆盖FOSUser登录表单:

  1. app/Resources/ Docs放置模板文件
  2. 覆盖子Bundle Docs中的Controller

然而,随着Symfony Flex,项目结构发生了重大变化。

至于选项#1:没有app/Resources文件夹了。我将模板存储在/templates中。

关于选项#2:不再有AppBundle。

现在,我扩展了FOSUser的安全控制器:

<?php

namespace App\Controller;

use FOS\UserBundle\Controller\SecurityController as BaseController;

class SecurityController extends BaseController
{
    public function renderLogin(array $data)
    {
        return $this->render('/Admin/Login/index.html', $data);
    }
}

该应用程序仍然呈现FOSUserBundle表单。我有一种感觉,我必须以某种方式注册avobe控制器。在FOSUser配置中,没有指令。怎么能实现这一目标?

php symfony symfony-flex
2个回答
2
投票

在Symfony 4中,您只需将文件放在/ templates / bundles / FosUserBundle中

希望能帮助到你。


-1
投票

我认为你遵循了良好的道路,但忘了改变你的配置。您需要告诉fosuser使用不同的表单文件。

检查this file,106和109行:)

我没有用flex检查这个解决方案,但是我的一个朋友用symfony 4做了它并且工作得很好。

© www.soinside.com 2019 - 2024. All rights reserved.