/** * @param Court $court The court object to add. */ protected function doAddCourt(Court $court) { // set the back reference to this object directly as using provided method either results // in endless loop or in multiple relations if (!$court->getPlayers()->contains($this)) { $playerCourt = new PlayerCourt(); $playerCourt->setCourt($court); $this->addPlayerCourt($playerCourt); $foreignCollection = $court->getPlayers(); $foreignCollection[] = $this; } }