| @@ 65-77 (lines=13) @@ | ||
| 62 | * @param ResourceObject $resource |
|
| 63 | * @param Attribute $definition |
|
| 64 | */ |
|
| 65 | protected function processAttributeToResource($object, ResourceObject $resource, Attribute $definition) |
|
| 66 | { |
|
| 67 | $name = $definition->getName(); |
|
| 68 | $getter = $definition->getGetter(); |
|
| 69 | ||
| 70 | $value = $object->$getter(); |
|
| 71 | ||
| 72 | if ($definition->hasType()) { |
|
| 73 | $value = $this->processTypeToResource($definition, $value); |
|
| 74 | } |
|
| 75 | ||
| 76 | $resource->setAttribute($name, $value); |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * Process data-type |
|
| @@ 175-191 (lines=17) @@ | ||
| 172 | * @param ResourceObject $resource |
|
| 173 | * @param Attribute $definition |
|
| 174 | */ |
|
| 175 | protected function processResourceToAttribute($object, ResourceObject $resource, Attribute $definition) |
|
| 176 | { |
|
| 177 | $name = $definition->getName(); |
|
| 178 | ||
| 179 | if (! $resource->hasAttribute($name)) { |
|
| 180 | return; |
|
| 181 | } |
|
| 182 | ||
| 183 | $value = $resource->getAttribute($name); |
|
| 184 | $setter = $definition->getSetter(); |
|
| 185 | ||
| 186 | if ($definition->hasType()) { |
|
| 187 | $value = $this->processResourceToType($definition, $value); |
|
| 188 | } |
|
| 189 | ||
| 190 | $object->$setter($value); |
|
| 191 | } |
|
| 192 | } |
|