我正在使用此类来覆盖fosUserBundle formHandler:
<?php
/*
* This file is part of the FOSUserBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ecommerce\UserBundle\Form\Handler;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\Request;
use FOS\UserBundle\Model\UserManagerInterface;
use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Mailer\MailerInterface;
use Ecommerce\boutiqueBundle\services\image;
use FOS\UserBundle\Form\Handler\ProfileFormHandler as BaseHandler;
class ProfileFormHandler extends BaseHandler
{
protected $upload='upload\logo\\';
protected $em;
public function __construct(Form $form, Request $request, UserManagerInterface $userManage)
{
parent::__construct($form, $request, $userManager);
}
public function setLogo($image_filename)
{
$image=$this->form['logo']->getData();
$image = new Image($image);
$image->resize_to(90, 75);
$image->save_as($image_filename);
}
protected function onSuccess(UserInterface $user)
{
$img=$this->form->getData('logo');
if($img!="" and $img!=null)
{
$MyuniqId=uniqid();
$this->setLogo($this->upload.$MyuniqId.'_'.$img->getClientOriginalName());
$image=$user->setLogo($MyuniqId.'_'.$img->getClientOriginalName());
}
$this->userManager->updateUser($user);
}
}
但我收到了这个错误:
致命错误:调用未定义的方法 FOS \ UserBundle \ Form \ Model \ CheckPassword :: getClientOriginalName()in /var/www/project/Sym/src/Ecommerce/UserBundle/Form/Handler/ProfileFormHandler.php 第49行
我试过了:
$this->form->setData($user);
但它也会返回错误。
感谢您提前回复。