werneckbh
3/30/2015 - 3:28 PM

Pai.php

<?php

use Doctrine\Common\Collections\ArrayCollection;

class Pai
{
    private $id;
    private $nome;
    /**
    * @ORM\OneToMany(targetEntity="Pai", mappedBy="pai")
    */
    private $filhos;
    /**
    * @ORM\ManyToOne(targetEntity="Pai", inversedBy="filhos")
    */
    private $pai;

    public function __construct()
    {
        $this->filhos = new ArrayCollection();
    }

    public function getId()
    {
        return $this->id;
    }

    public function getNome()
    {
        return $this->nome;
     }

    public function setNome($nome) 
    {
        $this->nome = $nome;
    }
    
    public function setPai($pai)
    {
        $this->pai = $pai;
    }
    
    public function getPai()
    {
        return $this->pai;
    }
    
    public function addFilhos($filho)
    {
        if(!$this->filhos->contains($filho)) {
            $this->filhos->add($filho);
        }
    }
    
    public function getFilhos()
    {
        return $this->filhos;
    }
    
    public function removeFilhos($filho)
    {
        if($this->filhos->contains->($filho)) {
            $this->filhos->removeElement($filho);
        }   
    }
}