Skip to content

Commit d5a8b29

Browse files
resolved warning issues while creating a new team
1 parent 2251921 commit d5a8b29

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

src/Api/ApigeeX/Controller/AppGroupMembersController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function getAppGroupAttributes(): AttributesProperty
114114
$appGroup = $this->responseToArray($this->client->get($this->getBaseEndpointUri()));
115115
$serializer = new AttributesPropertyAwareEntitySerializer();
116116
$appGroupAttributes = $serializer->denormalize(
117-
$appGroup['attributes'],
117+
$appGroup['attributes'] ?? '',
118118
AttributesProperty::class
119119
);
120120

src/Denormalizer/AttributesPropertyDenormalizer.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,20 @@ public function supportsDenormalization($data, $type, $format = null)
4848
*
4949
* {@inheritdoc}
5050
*/
51-
public function denormalize($data, $type, $format = null, array $context = [])
51+
public function denormalize($data, $type, $format = null, array $context = []): mixed
5252
{
5353
$flatten = [];
54-
foreach ($data as $key => $item) {
55-
if (is_object($item)) {
56-
// $data came from the EntityNormalizer.
57-
$flatten[$item->name] = $item->value ?? null;
58-
} else {
59-
$flatten[$key] = $item;
54+
// The Apigee X API omits the 'attributes' key entirely on new/empty
55+
// AppGroups (teams), so $data can be null here.
56+
if (!empty($data)) {
57+
foreach ($data as $key => $item) {
58+
if (is_object($item)) {
59+
// $data came from the EntityNormalizer.
60+
$flatten[$item->name] = $item->value ?? NULL;
61+
}
62+
else {
63+
$flatten[$key] = $item;
64+
}
6065
}
6166
}
6267
$data = $flatten;

0 commit comments

Comments
 (0)