我读了两种方法来覆盖FOSUser登录表单:
然而,随着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配置中,没有指令 . 怎么能实现这一目标?
2 回答
在Symfony 4中,您只需将文件放在/ templates / bundles / FosUserBundle中
希望能帮助到你 .
我认为你遵循了良好的道路,但忘了改变你的配置 . 您需要告诉fosuser使用不同的表单文件 .
检查this file,第106和109行:)
我没有用flex检查这个解决方案,但是我的一个朋友用symfony 4做了它并且工作得很好 .