gpt4 book ai didi

php - FOSUserBundle 覆盖注册但无法加载类型错误

转载 作者:行者123 更新时间:2023-12-02 08:02:27 25 4
gpt4 key购买 nike

我尝试使用 FOSUserBundle,我按照文档中的说明覆盖 Bundle,但是当我尝试在/login 工作时访问/register 时收到此错误(我没有覆盖它):

Could not load type "app_user_registration"
500 Internal Server Error - InvalidArgumentException

配置

Symfony 版本:3.1.7

FOSUserBundle 版本:dev-master

我的文件

应用程序/config/services.yml:

services:
app.form.registration:
class: CoreBundle\Form\Type\RegistrationFormType
tags:
- { name: form.type, alias: app_user_registration }

应用程序/config/config.yml:

fos_user:
db_driver: orm
firewall_name: main
user_class: CoreBundle\Entity\User
registration:
form:
type: app_user_registration

src/CoreBundle/Form/Type/RegistrationFormType.php

<?php
// src/CoreBundle/Form/Type/RegistrationFormType.php

namespace CoreBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

class RegistrationFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name');
}

public function getParent()
{
return 'fos_user_registration';
}

public function getName()
{
return 'app_user_registration';
}
}
?>

src/viwa/UserBundle/Controller/RegistrationController.php:

<?php
// src/viwa/UserBundle/Controller/RegistrationController.php

namespace viwa\UserBundle\Controller;

use Symfony\Component\HttpFoundation\RedirectResponse;
use FOS\UserBundle\Controller\RegistrationController as BaseController;

class RegistrationController extends BaseController
{
// Don't need to change this right now.
}
?>

src/viwa/UserBundle/viwaUserBundle.php:

<?php
// src/viwa/UserBundle/viwaUserBundle.php

namespace viwa\UserBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class viwaUserBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
}

如果您需要任何其他帮助我,我会编辑我的帖子。

希望有人能帮助我。

最佳答案

您的config.yml文件应该是:

fos_user:
db_driver: orm
firewall_name: main
user_class: CoreBundle\Entity\User
registration:
form:
type: CoreBundle\Form\Type\RegistrationFormType

在您的src/CoreBundle/Form/Type/RegistrationFormType.php中,getParent()函数应该是:

public function getParent()
{
return 'FOS\UserBundle\Form\Type\RegistrationFormType';
}

关于php - FOSUserBundle 覆盖注册但无法加载类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41824546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com