/** * * @param AttributeAware $entity * @dataProvider provideNamespacable */ public function testReadableEntities(AttributeAware $entity) { $bag = new AttributeBagNamespaced($entity, 'test.'); $this->assertSame($bag, $bag->getAttributeBag()); $entity->setAttribute('a.b', 'c'); $entity->setAttribute('test.d', 'e'); $this->assertEquals('e', $bag->getAttribute('d')); $this->assertNull($bag->getAttribute('a.b')); $this->assertNull($bag->getAttribute('test.d')); $this->assertEquals(array('d' => 'e'), $bag->getAttributes()); }
private function loadAttributes(SimpleXMLElement $xml, AttributeAware $target, array $keys) { // apply all default values for this type $type = $xml->getName(); foreach ($keys as $key) { if (isset($key['default']) && ($key['for'] === $type || $key['for'] === 'all')) { $target->setAttribute($key['name'], $key['default']); } } // apply all data attributes for this element foreach ($xml->data as $dataElem) { $key = $keys[(string) $dataElem['key']]; $target->setAttribute($key['name'], $this->castAttribute((string) $dataElem, $key['type'])); } }
/** * @param AttributeAware $attributeAware * @param Location $location */ private function addLocationTo(AttributeAware $attributeAware, Location $location) { $locations = $attributeAware->getAttribute('locations', array()); $locations[] = $location; $attributeAware->setAttribute('locations', $locations); }
/** * @depends testAttributeAwareInterface * @param AttributeAware $entity */ public function testAttributeBag(AttributeAware $entity) { $bag = $entity->getAttributeBag(); $this->assertInstanceOf('Fhaculty\\Graph\\Attribute\\AttributeBag', $bag); }
private function setLayout(AttributeAware $entity, array $layout) { $bag = new AttributeBagNamespaced($entity->getAttributeBag(), 'graphviz.'); $bag->setAttributes($layout); return $entity; }