/** * @param Template $template The template object to add. */ protected function doAddTemplate($template) { $attributeTemplate = new ChildAttributeTemplate(); $attributeTemplate->setTemplate($template); $this->addAttributeTemplate($attributeTemplate); // set the back reference to this object directly as using provided method either results // in endless loop or in multiple relations if (!$template->getAttributes()->contains($this)) { $foreignCollection = $template->getAttributes(); $foreignCollection[] = $this; } }