@@ 66-89 (lines=24) @@ | ||
63 | * @param ResourceObject $resource |
|
64 | * @param Attribute $definition |
|
65 | */ |
|
66 | protected function processAttributeToResource($object, ResourceObject $resource, Attribute $definition) |
|
67 | { |
|
68 | $name = $definition->getName(); |
|
69 | $getter = $definition->getGetter(); |
|
70 | ||
71 | $value = $object->$getter(); |
|
72 | ||
73 | if ($value === null && ! $definition->getProcessNull()) { |
|
74 | return; |
|
75 | } |
|
76 | ||
77 | if ($definition->isMany()) { |
|
78 | $value = $this->processIterableValueToResource($value, $definition); |
|
79 | ||
80 | $resource->setAttribute($name, $value); |
|
81 | return; |
|
82 | } |
|
83 | ||
84 | if ($definition->hasType()) { |
|
85 | $value = $this->processTypeToResource($definition, $value); |
|
86 | } |
|
87 | ||
88 | $resource->setAttribute($name, $value); |
|
89 | } |
|
90 | ||
91 | /** |
|
92 | * Process value declared as many (iterable) |
|
@@ 214-240 (lines=27) @@ | ||
211 | * @param ResourceObject $resource |
|
212 | * @param Attribute $definition |
|
213 | */ |
|
214 | protected function processResourceToAttribute($object, ResourceObject $resource, Attribute $definition) |
|
215 | { |
|
216 | $name = $definition->getName(); |
|
217 | ||
218 | if (! $resource->hasAttribute($name)) { |
|
219 | return; |
|
220 | } |
|
221 | ||
222 | $value = $resource->getAttribute($name); |
|
223 | ||
224 | if ($value === null && ! $definition->getProcessNull()) { |
|
225 | return; |
|
226 | } |
|
227 | ||
228 | if ($definition->isMany()) { |
|
229 | $this->processIterableValueFromResource($value, $object, $definition); |
|
230 | return; |
|
231 | } |
|
232 | ||
233 | $setter = $definition->getSetter(); |
|
234 | ||
235 | if ($definition->hasType()) { |
|
236 | $value = $this->processResourceToType($definition, $value); |
|
237 | } |
|
238 | ||
239 | $object->$setter($value); |
|
240 | } |
|
241 | ||
242 | /** |
|
243 | * Process iterable value |