| | 42 | |
|---|
| | 43 | /** |
|---|
| | 44 | * Add all attributes using the appropriate setter methods |
|---|
| | 45 | * |
|---|
| | 46 | * @param Tag $tag |
|---|
| | 47 | * @param Definition $def |
|---|
| | 48 | * @param array $array |
|---|
| | 49 | */ |
|---|
| | 50 | protected function addAttributesToValue(Tag $tag, TagDefinition $def, $array) |
|---|
| | 51 | { |
|---|
| | 52 | // set all attributes |
|---|
| | 53 | foreach ($def->getAttributes() as $att) { |
|---|
| | 54 | $val = $att->convertValue($tag); |
|---|
| | 55 | // attribute has not been set and there is no |
|---|
| | 56 | // default value, skip the method call |
|---|
| | 57 | if (null == $val) { |
|---|
| | 58 | continue; |
|---|
| | 59 | } |
|---|
| | 60 | |
|---|
| | 61 | $array[$att->getName()] = $val; |
|---|
| | 62 | } |
|---|
| | 63 | |
|---|
| | 64 | return $array; |
|---|
| | 65 | } |
|---|
| | 66 | |
|---|
| | 67 | /** |
|---|
| | 68 | * Add all children to the created instance |
|---|
| | 69 | * |
|---|
| | 70 | * @param Tag $tag |
|---|
| | 71 | * @param Definition $def |
|---|
| | 72 | * @param array $array |
|---|
| | 73 | */ |
|---|
| | 74 | protected function addChildrenToValue(Tag $tag, Definition $def, $array) |
|---|
| | 75 | { |
|---|
| | 76 | // traverse all children |
|---|
| | 77 | $children = $tag->getChildren(); |
|---|
| | 78 | if (count($children) == 0) { |
|---|
| | 79 | return $array; |
|---|
| | 80 | } |
|---|
| | 81 | |
|---|
| | 82 | foreach ($children as $child) { |
|---|
| | 83 | $val = $child->getConvertedValue(); |
|---|
| | 84 | // attribute has not been set and there is no |
|---|
| | 85 | // default value, skip the method call |
|---|
| | 86 | if (null == $val) { |
|---|
| | 87 | continue; |
|---|
| | 88 | } |
|---|
| | 89 | |
|---|
| | 90 | $childDef = $child->getDefinition(); |
|---|
| | 91 | if ($childDef->getName() == '__none') { |
|---|
| | 92 | $array[] = $val; |
|---|
| | 93 | } else { |
|---|
| | 94 | $array[$child->getName()] = $val; |
|---|
| | 95 | } |
|---|
| | 96 | } |
|---|
| | 97 | |
|---|
| | 98 | return $array; |
|---|
| | 99 | } |
|---|