/** * @param Country $country The country object to add. */ protected function doAddCountry($country) { $couponCountry = new ChildCouponCountry(); $couponCountry->setCountry($country); $this->addCouponCountry($couponCountry); // set the back reference to this object directly as using provided method either results // in endless loop or in multiple relations if (!$country->getCoupons()->contains($this)) { $foreignCollection = $country->getCoupons(); $foreignCollection[] = $this; } }