protected function doAddToAllTemplates(AttributeModel $attribute) { $templates = TemplateQuery::create()->find(); foreach ($templates as $template) { $attribute_template = new AttributeTemplate(); if (null === AttributeTemplateQuery::create()->filterByAttribute($attribute)->filterByTemplate($template)->findOne()) { $attribute_template->setAttribute($attribute)->setTemplate($template)->save(); } } }
/** * @param Attribute $attribute The attribute object to add. */ protected function doAddAttribute($attribute) { $attributeTemplate = new ChildAttributeTemplate(); $attributeTemplate->setAttribute($attribute); $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 (!$attribute->getTemplates()->contains($this)) { $foreignCollection = $attribute->getTemplates(); $foreignCollection[] = $this; } }