I am using Symfony 2.0.
I have an Employee class which extends from BaseUser
I need to override setUsername
method (among others) :
My method is Employee.php is like that :
public function setUsername()
{
$name=$this->getName();
$this->username=($name);//just an example
}
But when I clear the cache I have the error :
MyBundle\Entity\Employee::setUsername() must be compatible with that of FOS\UserBundle\Model\UserInterface::setUsername()
EDIT :
I have seen that the method setUsername in FOS\UserBundle\Model\UserInterface need the $username
argument, but my setUsername
function as it is defined doesn't need this argument. More generally, my question is how to redefine/override methods and also how to add his own constraints to fields and methods defined in Fos User. Thanks a lot
How can I override this function? I tried parent::setUsername()
but I have a parse error:
PHP Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting '('