/**
* My\FrontendBundle\Entity\Mountain
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="My\FrontendBundle\Entity\MountainRepository")
*/
class Mountain
{
private $id;
private $name;
private $height;
public function __toString()
{
return $this->getName();
}
public function fromArray(array $data)
{
foreach ($data as $key => $value) {
$methodName = 'set' . ucfirst($key);
$this->$methodName($value);
}
}
public function getId()
{
...
}
public function setName($name)
{
...
}
...
}
Listing 19.11. Zarys zmodyfikowanego pliku Mountain.php
Rozdział 19. Dostosowywanie klas dostępu do bazy danych