我使用official documentation for symfony 2.1來覆蓋默認的FOSUserBundle表單。但是,當我試圖重寫表單處理程序,我得到這個錯誤:覆蓋默認的FOSUserBundle表單:InvalidArgumentException
InvalidArgumentException: The service definition "test_user.form.handler.registration" does not exist.
文件清單:
<?php
// src/Test/UserBundle/Form/Handler/RegistrationFormHandler.php
namespace Test\UserBundle\Form\Handler;
use FOS\UserBundle\Form\Handler\RegistrationFormHandler as BaseHandler;
use FOS\UserBundle\Model\UserInterface;
class RegistrationFormHandler extends BaseHandler
{
protected function onSuccess(UserInterface $user, $confirmation)
{
// logic here...
parent::onSuccess($user, $confirmation);
}
}
= - = - = - = - =
# src/Test/UserBundle/Resources/config/services.yml
services:
test_user.form.handler.registration:
class: Test\UserBundle\Form\Handler\RegistrationFormHandler
arguments: ["@fos_user.registration.form", "@request", "@fos_user.user_manager", "@fos_user.mailer", "@fos_user.util.token_generator"]
scope: request
public: false
= - = - = - = - =
# app/config/config.yml
fos_user:
db_driver: orm
firewall_name: dev
user_class: Test\UserBundle\Entity\User
registration:
form:
handler: test_user.form.handler.registration
PS是的,我已經閱讀過類似的問題,但並不是我有同樣的問題。
問題很簡單。我手動創建了我的'UnserBundle',因此沒有創建名爲'DependencyInjection'的文件夾。這個文件夾包含php文件,它加載了服務配置。 – Hast