FOSUserBundle覆盖注册,但无法加载类型错误 [英] FOSUserBundle overwrite registration but Could not load type error

查看:63
本文介绍了FOSUserBundle覆盖注册,但无法加载类型错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I tried to use the FOSUserBundle, I followed the instructions on the documentation for overwriting the Bundle, but I get this error when I try to access to /register while /login works (I didn't overwrite it):

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

配置

Symfony版本: 3.1.7

Symfony version: 3.1.7

FOSUserBundle版本: dev-master

FOSUserBundle version: dev-master

我的文件

app/config/services.yml:

app/config/services.yml:

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

app/config/config.yml:

app/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

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:

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:

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';
    }
}

如果您需要其他任何帮助,我可以编辑我的帖子.

If you need anything other to help me I edit my post.

希望任何人都可以帮助我.

Hope anyone can help me out.

推荐答案

您的 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';
}

这篇关于FOSUserBundle覆盖注册,但无法加载类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆