phonenumbers[] = $phone; if ($phone->user !== $this) { $phone->user = $this; } } public function addArticle(CmsArticle $article) { $this->articles[] = $article; if ($article->user !== $this) { $article->user = $this; } } public function addGroup(CmsGroup $group) { $this->groups[] = $group; $group->addUser($this); } public function getGroups() { return $this->groups; } public function removePhonenumber($index) { if (isset($this->phonenumbers[$index])) { $ph = $this->phonenumbers[$index]; unset($this->phonenumbers[$index]); $ph->user = null; return true; } return false; } }