/** * @param Coupon $coupon The coupon object to add. */ protected function doAddCoupon($coupon) { $couponCountry = new ChildCouponCountry(); $couponCountry->setCoupon($coupon); $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 (!$coupon->getCountries()->contains($this)) { $foreignCollection = $coupon->getCountries(); $foreignCollection[] = $this; } }