|
7 | 7 | * you may not use this file except in compliance with the License. |
8 | 8 | * You may obtain a copy of the License at |
9 | 9 | * |
10 | | - * https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * https://www.apache.org/licenses/LICENSE-2.0 |
11 | 11 | * |
12 | 12 | * Unless required by applicable law or agreed to in writing, software |
13 | 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
@@ -111,11 +111,30 @@ public function update(EntityInterface $entity): void |
111 | 111 | $uri = $this->getEntityEndpointUri($developer_entity->originalEmail()); |
112 | 112 | $response = $this->getClient()->put( |
113 | 113 | $uri, |
114 | | - $this->getEntitySerializer()->serialize($developer_entity, 'json') |
| 114 | + $this->getEntitySerializer()->serialize($developer_entity, 'json', ['ignored_attributes' => ['originalEmail']]) |
115 | 115 | ); |
116 | 116 | $this->getEntitySerializer()->setPropertiesFromResponse($response, $developer_entity); |
117 | 117 | } |
118 | 118 |
|
| 119 | + /** |
| 120 | + * Ensure 'originalEmail' is not included when creating developers. |
| 121 | + * |
| 122 | + * {@inheritdoc} |
| 123 | + */ |
| 124 | + protected function buildEntityCreatePayload(EntityInterface $entity, array $context = []): string |
| 125 | + { |
| 126 | + if ($entity instanceof Developer) { |
| 127 | + $ignored = $context['ignored_attributes'] ?? []; |
| 128 | + $ignored[] = 'originalEmail'; |
| 129 | + $context['ignored_attributes'] = array_values(array_unique($ignored)); |
| 130 | + } |
| 131 | + |
| 132 | + // The original implementation (from trait) simply delegates to the |
| 133 | + // entity serializer. Mirror that behavior here while applying our |
| 134 | + // adjusted context. |
| 135 | + return $this->getEntitySerializer()->serialize($entity, 'json', $context); |
| 136 | + } |
| 137 | + |
119 | 138 | /** |
120 | 139 | * {@inheritdoc} |
121 | 140 | */ |
|
0 commit comments