Index: trunk/extensions/Wikidata/OmegaWiki/Fetcher.php |
— | — | @@ -13,8 +13,14 @@ |
14 | 14 | $this->attributeLevel = $attributeLevel; |
15 | 15 | $this->attribute = $attribute; |
16 | 16 | } |
| 17 | + |
17 | 18 | public function fetch($keyPath) { |
18 | | - return $keyPath->peek($this->attributeLevel)->getAttributeValue($this->attribute); |
| 19 | + $key = $keyPath->peek($this->attributeLevel); |
| 20 | + |
| 21 | + if ($key->getStructure()->supportsAttribute($this->attribute)) |
| 22 | + return $key->getAttributeValue($this->attribute); |
| 23 | + else |
| 24 | + return null; |
19 | 25 | } |
20 | 26 | } |
21 | 27 | |
Index: trunk/extensions/Wikidata/OmegaWiki/Attribute.php |
— | — | @@ -34,11 +34,11 @@ |
35 | 35 | if(is_null($this->id) && ($this->type instanceof Structure)) { |
36 | 36 | $this->id = $this->type->getStructureType(); |
37 | 37 | // Override structure label with a more specific one |
38 | | - } elseif(!is_null($this->id) && ($this->type instanceof Structure)) { |
| 38 | + } |
| 39 | + elseif(!is_null($this->id) && ($this->type instanceof Structure)) { |
39 | 40 | $this->type->setStructureType($this->id); |
40 | 41 | } |
41 | 42 | } |
42 | | - |
43 | 43 | } |
44 | 44 | |
45 | 45 | class Structure { |
— | — | @@ -122,9 +122,12 @@ |
123 | 123 | return "Structure(" . implode(", ", $this->attributeIds) . ")"; |
124 | 124 | } |
125 | 125 | |
| 126 | + public function supportsAttribute(Attribute $attribute) { |
| 127 | + return $this->supportsAttributeId($attribute->id); |
| 128 | + } |
| 129 | + |
126 | 130 | public function supportsAttributeId($attributeId) { |
127 | | - return true; |
128 | | -// return in_array($attributeId, $this->attributeIds); |
| 131 | + return in_array($attributeId, $this->attributeIds); |
129 | 132 | } |
130 | 133 | } |
131 | 134 | |