symfony2:注册而不在FOSUserBundle的PUGXMultiUserBundle中记录用户

时间:2014-06-01 01:27:40

标签: symfony controller fosuserbundle override pugxmultiuserbundle

我需要在注册后禁用记录新用户的默认行为 我知道这是FOSUserBundle问题,但我使用覆盖默认控制器的PUGXMultiUserBundle

class RegistrationUserTwoController extends Controller
{
 public function registerAction()
 {
   return $this->container
              ->get('pugx_multi_user.registration_manager')
              ->register('Acme\UserBundle\Entity\UserTwo');
  }
}

任何回复都将不胜感激。

1 个答案:

答案 0 :(得分:1)

尽管使用了MultiUserBundle,您仍应覆盖在AuthenticationListenerFOSUserEvents::REGISTRATION_COMPLETED事件期间负责对用户进行身份验证的默认FosUserBundle FOSUserEvents::REGISTRATION_CONFIRMED

这个课程在这里找到: 供应商/ friendsofsymfony /用户束/ FOS / UserBundle /事件监听/ AuthenticationListener.php

您可以将此类用作您自己的监听器的基础,并使用fos_user.listener.authentication作为您的捆绑包parameters文件中services.yml的服务ID设置您的班级。

 parameters:    
     fos_user.listener.authentication: Acme\FooBundle\Authentication\MyAuthenticationListener

如果您不熟悉服务覆盖,那么本教程将帮助您:
http://symfony.com/doc/current/cookbook/bundles/override.html#services-configuration