我使用此documentation安装了PUGXMultiUserBundle,但我遵循了这个步骤,但是我遇到了错误
类型错误:传递给FOS \ UserBundle \ Controller \ RegistrationController :: __ construct()的参数1必须实现Symfony \ Component \ EventDispatcher \ EventDispatcherInterface接口,未提供任何接口...
/**
* Class RegistrationSimpleUserController
* @package AppBundle\Controller
*
*/
class RegistrationSimpleUserController extends Controller
{
/**
* @return mixed
*
*
* @Route("/register/simple", name="registration_simple_user")
*/
public function registerAction()
{
return $this->container
->get('pugx_multi_user.registration_manager')
->register('Acme\UserBundle\Entity\UserOne');
}
}
这是我的RegistrationSimpleUserController:
{{1}}
答案 0 :(得分:1)
我认为这是PUGX捆绑软件中的错误,尚未更新。
他们将FOSUserBundle注册控制器定义为这样的服务:
pugx_multi_user.registration_controller:
class: FOS\UserBundle\Controller\RegistrationController
但是FOSUserBundle中的RegistrationController具有一些依赖性:
public function __construct(EventDispatcherInterface $eventDispatcher, FactoryInterface $formFactory, UserManagerInterface $userManager, TokenStorageInterface $tokenStorage)
{
$this->eventDispatcher = $eventDispatcher;
$this->formFactory = $formFactory;
$this->userManager = $userManager;
$this->tokenStorage = $tokenStorage;
}
我认为您可以通过定义这样的别名来解决它:
pugx_multi_user.registration_controller:
alias: fos_user.registration.controller
或在您自己的services.yml中覆盖整个定义:
pugx_multi_user.registration_controller:
class: FOS\UserBundle\Controller\RegistrationController
arguments:
- '@event_dispatcher'
- '@fos_user.registration.form.factory'
- '@fos_user.user_manager'
- '@security.token_storage'