From 95eb914a47cb9ffa561953b92f5fcd4d235cf567 Mon Sep 17 00:00:00 2001 From: shailesh-google Date: Thu, 5 Feb 2026 19:40:30 +0530 Subject: [PATCH] Ignore 'originalEmail' when creating developer entities Updated the serialization process to ignore 'originalEmail' when creating developers. Adjusted the context for entity creation to ensure 'originalEmail' is not included. --- .../Controller/DeveloperController.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Api/Management/Controller/DeveloperController.php b/src/Api/Management/Controller/DeveloperController.php index 483adf650..7c95340dc 100644 --- a/src/Api/Management/Controller/DeveloperController.php +++ b/src/Api/Management/Controller/DeveloperController.php @@ -7,7 +7,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -111,11 +111,30 @@ public function update(EntityInterface $entity): void $uri = $this->getEntityEndpointUri($developer_entity->originalEmail()); $response = $this->getClient()->put( $uri, - $this->getEntitySerializer()->serialize($developer_entity, 'json') + $this->getEntitySerializer()->serialize($developer_entity, 'json', ['ignored_attributes' => ['originalEmail']]) ); $this->getEntitySerializer()->setPropertiesFromResponse($response, $developer_entity); } + /** + * Ensure 'originalEmail' is not included when creating developers. + * + * {@inheritdoc} + */ + protected function buildEntityCreatePayload(EntityInterface $entity, array $context = []): string + { + if ($entity instanceof Developer) { + $ignored = $context['ignored_attributes'] ?? []; + $ignored[] = 'originalEmail'; + $context['ignored_attributes'] = array_values(array_unique($ignored)); + } + + // The original implementation (from trait) simply delegates to the + // entity serializer. Mirror that behavior here while applying our + // adjusted context. + return $this->getEntitySerializer()->serialize($entity, 'json', $context); + } + /** * {@inheritdoc} */