| @@ 52-66 (lines=15) @@ | ||
| 49 | * @param ResourceObject $resource |
|
| 50 | * @param Attribute $definition |
|
| 51 | */ |
|
| 52 | protected function processAttributeToResource($object, ResourceObject $resource, Attribute $definition) |
|
| 53 | { |
|
| 54 | $name = $definition->getName(); |
|
| 55 | $getter = $definition->getGetter(); |
|
| 56 | ||
| 57 | $value = $object->$getter(); |
|
| 58 | ||
| 59 | if ($value === null && ! $definition->getProcessNull()) { |
|
| 60 | return; |
|
| 61 | } |
|
| 62 | ||
| 63 | $value = $this->typeManager->toResource($definition, $value); |
|
| 64 | ||
| 65 | $resource->setAttribute($name, $value); |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * {@inheritdoc} |
|
| @@ 92-110 (lines=19) @@ | ||
| 89 | * @param ResourceObject $resource |
|
| 90 | * @param Attribute $definition |
|
| 91 | */ |
|
| 92 | protected function processResourceToAttribute($object, ResourceObject $resource, Attribute $definition) |
|
| 93 | { |
|
| 94 | $name = $definition->getName(); |
|
| 95 | ||
| 96 | if (! $resource->hasAttribute($name)) { |
|
| 97 | return; |
|
| 98 | } |
|
| 99 | ||
| 100 | $value = $resource->getAttribute($name); |
|
| 101 | ||
| 102 | if ($value === null && ! $definition->getProcessNull()) { |
|
| 103 | return; |
|
| 104 | } |
|
| 105 | ||
| 106 | $value = $this->typeManager->fromResource($definition, $value); |
|
| 107 | $setter = $definition->getSetter(); |
|
| 108 | ||
| 109 | $object->$setter($value); |
|
| 110 | } |
|
| 111 | } |
|