コード例 #1
0
ファイル: Attribute.php プロジェクト: margery/thelia
 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();
         }
     }
 }
コード例 #2
0
ファイル: Template.php プロジェクト: margery/thelia
 /**
  * @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;
     }
 }