Let's say I have a class User:
$user = new User(1);
$user->setName('Bob');
$user->setGender('Male');
echo $user->getName();
echo $user->getGender();
echo $user->getDesignation()
Now, in Symfony2, with Doctrine2, it seems that Entitythis is the object that is used to create the database link. So I think that all the functions setName(), setGender(), getName()and getGender()must be within the file that is located in EntityBundle (because these functions UPDATE, or SELECT from the database).
But what about getDesignation()?
public function getDesignation() {
if ($this->getGender() == 'Male') return "Mr. ".$this->getName();
else return "Ms. ".$this->getName();
}
Is it possible to put a function that has absolutely no connection with the database in Entity? Is this not a bad practice?
lepix source
share