为了不断努力将多用户捆绑包合并到项目中,我得到了
呈现模板期间引发异常 ("无法为命名路由生成 URL "fos_user_registration_register"这样的路线不存在。在 FOSUserBundle:Registration:register_content.html.twig 在第 3 行。
我已经多次浏览了文档,但还没有看到在以下配置中我在哪里犯了错误。 在开发中,当我转到/register/staff 时,会发生上述错误。 无法弄清楚我们如何获得原始 fos 注册。
编辑:下面附加的堆栈跟踪,显示向FOSUserBundle的过渡
配置.yml
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: VolVolBundleEntityPerson
# registration:
# form:
# type: vol_user_registration
service:
user_manager: pugx_user_manager
pugx_multi_user:
users:
staff:
entity:
class: VolVolBundleEntityStaff
# factory:
registration:
form:
type: VolVolBundleFormRegistrationStaffFormType
name: fos_user_registration_form
validation_groups: [Registration, Default]
template: VolVolBundle:Registration:staff.form.html.twig
profile:
form:
type: VolVolBundleFormProfileStaffFormType
name: fos_user_profile_form
validation_groups: [Profile, Default]
volunteer:
entity:
class: VolVolBundleEntityVolunteer
registration:
form:
type: VolVolBundleFormRegistrationVolunteerFormType
template: VolVolBundle:Registration:volunteer.form.html.twig
profile:
form:
type: VolVolBundleFormProfileVolunteerFormType
路由.yml:
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
#rem'd for PUGX multi-user bundle
#fos_user_register:
# resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
# prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
##add following for PUGX multi-user bundle
staff_registration:
pattern: /register/staff
defaults: { _controller: VolVolBundle:RegistrationStaff:register }
volunteer_registration:
pattern: /register/volunteer
defaults: { _controller: VolVolBundle:RegistrationVolunteer:register }
控制器:
class RegistrationStaffController extends Controller
{
/**
* @return type
*/
public function registerAction()
{
return $this->container
->get('pugx_multi_user.registration_manager')
->register('VolVolBundleEntityStaff');
}
}
根据要求,模板staff.form.html.twig&staff_register_content.html.twig:
//staff.form.html.twig
{% extends 'VolVolBundle:Default:layout.html.twig' %}
{% block body %}
Staff Registration Form
{% block fos_user_content %}
{% include 'VolVolBundle:Registration:staff_register_content.html.twig' %}
{% endblock fos_user_content %}
{% endblock %}
//staff_register_content.html.twig
{% trans_default_domain 'FOSUserBundle' %}
<form action="{{ path('staff_registration') }}" {{ form_enctype(form) }} method="POST">
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'registration.submit'|trans }}" />
</div>
</form>
默认布局:
<!DOCTYPE html >
<head>
{% stylesheets '@VolVolBundle/Resources/public/css/*' filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}" />
{% endstylesheets %}</head>
<body class="background" >
{% block body %}
{% endblock %}
</body>
堆栈跟踪
at SymfonyBundleTwigBundleTwigEngine->renderResponse('FOSUserBundle:Registration:register.html.twig', array('form' => object(FormView)))
in G:Documentsworkspacevolunteervendorfriendsofsymfonyuser-bundleFOSUserBundleControllerRegistrationController.php line 78
at FOSUserBundleControllerRegistrationController->registerAction(object(Request))
in G:Documentsworkspacevolunteervendorpugxmulti-user-bundlePUGXMultiUserBundleControllerRegistrationManager.php line 63
at PUGXMultiUserBundleControllerRegistrationManager->register('VolVolBundleEntityStaff')
in G:DocumentsworkspacevolunteersrcVolVolBundleControllerRegistrationStaffController.php line 25
at VolVolBundleControllerRegistrationStaffController->registerAction()
in line
at call_user_func_array(array(object(RegistrationStaffController), 'registerAction'), array())
in G:Documentsworkspacevolunteerappbootstrap.php.cache line 2911
at SymfonyComponentHttpKernelHttpKernel->handleRaw(object(Request), '1')
in G:Documentsworkspacevolunteerappbootstrap.php.cache line 2883
at SymfonyComponentHttpKernelHttpKernel->handle(object(Request), '1', true)
in G:Documentsworkspacevolunteerappbootstrap.php.cache line 3022
at SymfonyComponentHttpKernelDependencyInjectionContainerAwareHttpKernel->handle(object(Request), '1', true)
in G:Documentsworkspacevolunteerappbootstrap.php.cache line 2303
at SymfonyComponentHttpKernelKernel->handle(object(Request))
in G:Documentsworkspacevolunteerwebapp_dev.php line 28
'VolVolBundle:Default:layout.html.twig' 是否包含注册链接?
fos_user_registration_register
路由正在其中一个模板中的某个位置调用。
捆绑包指令的误解。 修订后的 routeting.yml,其中fos_user_register没有被注释掉!
路由.yml
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "@FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
##add following for PUGX multi-user bundle
staff_registration:
pattern: /register/staff
defaults: { _controller: VolVolBundle:RegistrationStaff:register }
volunteer_registration:
pattern: /register/volunteer
defaults: { _controller: VolVolBundle:RegistrationVolunteer:register }
看上面,我猜你的VolVolBundle:Default:layout.html.twig
里面没有{% block body %}
块?
如果VolVolBundle:Default:layout.html.twig
是FOSUserBunde::layout.html.twig
模板的副本,则不会,这意味着您的{% block fos_user_content %}
很可能不会覆盖布局模板,并且(以某种方式)正在使用 FOSUserBundle 默认值。
您也可以发布您的VolVolBundle:Default:layout.html.twig
模板吗?