Skip to content

Commit 08db163

Browse files
Ignore 'originalEmail' when creating developer entities (#467)
Updated the serialization process to ignore 'originalEmail' when creating developers. Adjusted the context for entity creation to ensure 'originalEmail' is not included.
1 parent 6814b99 commit 08db163

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

src/Api/Management/Controller/DeveloperController.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* you may not use this file except in compliance with the License.
88
* You may obtain a copy of the License at
99
*
10-
* https://www.apache.org/licenses/LICENSE-2.0
10+
* https://www.apache.org/licenses/LICENSE-2.0
1111
*
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -111,11 +111,30 @@ public function update(EntityInterface $entity): void
111111
$uri = $this->getEntityEndpointUri($developer_entity->originalEmail());
112112
$response = $this->getClient()->put(
113113
$uri,
114-
$this->getEntitySerializer()->serialize($developer_entity, 'json')
114+
$this->getEntitySerializer()->serialize($developer_entity, 'json', ['ignored_attributes' => ['originalEmail']])
115115
);
116116
$this->getEntitySerializer()->setPropertiesFromResponse($response, $developer_entity);
117117
}
118118

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+
119138
/**
120139
* {@inheritdoc}
121140
*/

0 commit comments

Comments
 (0)