. */ namespace Volkszaehler\Model; use Volkszaehler\Interpreter; use Doctrine\ORM; use Doctrine\Common\Collections; use Doctrine\Common\Collections\ArrayCollection; /** * Aggregator entity * * @author Steffen Vogel * @package default * @todo use nested sets: http://github.com/blt04/doctrine2-nestedset * * @Entity */ class Aggregator extends Entity { /** * @ManyToMany(targetEntity="Entity", inversedBy="parents") * @JoinTable(name="entities_in_aggregator", * joinColumns={@JoinColumn(name="parent_id", referencedColumnName="id")}, * inverseJoinColumns={@JoinColumn(name="child_id", referencedColumnName="id")} * ) */ protected $children = NULL; /** * Construct */ public function __construct($properties = array()) { parent::__construct($properties); $this->channels = new ArrayCollection(); $this->children = new ArrayCollection(); } /** * Adds entity as new child * * @param Entity $child * @todo check if the entity is already member of the group * @todo add bidrectional association */ public function addChild(Entity $child) { $this->children->add($child); } /** * Remove child from group * * @param Entity $child * @todo check if the entity is member of the group * @todo add bidrectional association */ public function removeChild(Entity $child) { return $this->children->removeElement($child); } /* * Setter & getter */ public function getChildren() { return $this->children->toArray(); } } ?>