Ejemplo n.º 1
0
 public function output()
 {
     $attributesString = '';
     $childrenString = '';
     /** @var \DOM\Attribute $attribute */
     foreach ($this->attributes->sort()->toArray() as &$attribute) {
         if (!in_array($attribute->getName(), array('id', 'class')) || !$attribute->isEmpty()) {
             $attributesString .= ' ' . $attribute->output();
         }
     }
     /** @var \DOM\Node $child */
     foreach ($this->children->toArray() as $child) {
         $childrenString .= $child->output();
     }
     return sprintf('<%s%s>%s</%s>', $this->name, $attributesString, $childrenString, $this->name);
 }
Ejemplo n.º 2
0
 public function GetAttributes($category, $entityIds = array())
 {
     if (!is_array($entityIds) && !empty($entityIds)) {
         $entityIds = array($entityIds);
     }
     $attributeList = new AttributeList();
     $attributes = $this->attributeRepository->GetByCategory($category);
     $stopwatch = new StopWatch();
     $stopwatch->Start();
     $values = $this->attributeRepository->GetEntityValues($category, $entityIds);
     foreach ($attributes as $attribute) {
         $attributeList->AddDefinition($attribute);
     }
     foreach ($values as $value) {
         $attributeList->AddValue($value);
     }
     $stopwatch->Stop();
     Log::Debug('Took %d seconds to load custom attributes for category %s', $stopwatch->GetTotalSeconds(), $category);
     return $attributeList;
 }
Ejemplo n.º 3
0
 public function testGetsAttributeValuesForEntity()
 {
     $entityId = 400;
     $attribute1 = new TestCustomAttribute(1, 'a1');
     $attribute2 = new TestCustomAttribute(2, 'a2');
     $attribute3 = new TestCustomAttribute(3, 'a3');
     $value1 = new AttributeEntityValue(1, $entityId, 'att1');
     $value3 = new AttributeEntityValue(3, $entityId, 'att3');
     $value4 = new AttributeEntityValue(4, $entityId, 'att2');
     $list = new AttributeList();
     $list->AddDefinition($attribute1);
     $list->AddDefinition($attribute2);
     $list->AddDefinition($attribute3);
     $list->AddValue($value1);
     $list->AddValue($value3);
     $list->AddValue($value4);
     $values = $list->GetAttributes($entityId);
     $this->assertEquals(array(new Attribute($attribute1, 'att1'), new Attribute($attribute2, null), new Attribute($attribute3, 'att3')), $values);
 }
Ejemplo n.º 4
0
 public static function Create($attribute)
 {
     AttributeList::create(array('attribute_id' => $attribute->attribute_id, 'name' => $attribute->name));
 }