simple question but i don’t know how to do it.
As an example we have User Entity for login (class below), how can i change $password to $accountPass ? Ofcourse it means that all relationships must be applied as it is $password, and all symfony2 classes must understand that variable (old) $password now is (changed to) $accountPass.
Question is about “names of variables”… Anyone know how to deal with it?
User Entity :
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity()
* @ORM\Table(name="_account")
* @UniqueEntity("username")
*/
class User implements UserInterface
{
public function __construct()
{
$this->salt = md5(uniqid(null, true));
$this->isActive = true;
}
/**
* Get roles
*
* @return string
*/
public function getRoles()
{
return array('ROLE_USER');
}
/**
*
*
* @return
*/
public function eraseCredentials()
{
}
/**
* Get equals
*
* @return boolean
*/
public function equals(UserInterface $user)
{
return $user->getUsername() == $this->getUsername();
}
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="username", type="string", length=255, unique=true)
*/
protected $username;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=255)
*/
protected $password;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=255)
*/
protected $email;
/**
* @var string
*
* @ORM\Column(name="salt", type="string", length=255)
*/
protected $salt;
/**
* @var boolean
* @ORM\Column(name="isActive", type="boolean")
*/
protected $isActive;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set username
*
* @param string $username
* @return User
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* Get username
*
* @return string
*/
public function getUsername()
{
return $this->username;
}
/**
* Set password
*
* @param string $password
* @return User
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Get password
*
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* Set email
*
* @param string $email
* @return User
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set salt
*
* @param string $salt
* @return User
*/
public function setSalt($salt)
{
$this->salt = $salt;
return $this;
}
/**
* Get salt
*
* @return string
*/
public function getSalt()
{
return $this->salt;
}
/**
* Set isActive
*
* @param string $isActive
* @return User
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return string
*/
public function getIsActive()
{
return $this->isActive;
}
}
Check this answer: https://stackoverflow.com/a/12147185/927636
You have to map all fields in your Entity class and name them as you want to.