0
我在我的項目中使用了FOS捆綁包。我在管理包中創建了一個新的控制器ChangePasswordController
。這是我的代碼。如何覆蓋symfony2中FOS捆綁包的驗證消息
namespace Pondip\AdminBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use FOS\UserBundle\Controller\ChangePasswordController as BaseController;
/**
Controller managing the change password *
@author Aman
/
class ChangePasswordController extends BaseController
{
/**
This action is used for change password for admin.
@author Aman
@return render view
@throws AccessDeniedException as exception
@
*/
public function changePasswordAction()
{
$user = $this->container->get('security.context')->getToken()->getUser();
$form = $this->container->get('fos_user.change_password.form');
$formHandler = $this->container->get('fos_user.change_password.form.handler');
$process = $formHandler->process($user);
if ($process) {
$this->setFlash('fos_user_success', 'Password has been changed successfully');
$url = $this->container->get('router')->generate('pondip_admin_changepassword');
return new RedirectResponse($url);
}
return $this->container->get('templating')->renderResponse(
'PondipAdminBundle:ChangePassword:changePassword.html.'.$this->container->getParameter('fos_user.template.engine'),
array('form' => $form->createView())
);
}
}
現在我想爲當前密碼自定義錯誤消息。