From d846fea6b04794304a6436a741b6bcb454462ed1 Mon Sep 17 00:00:00 2001 From: Rishad Omar Date: Thu, 5 Sep 2019 14:09:07 +0200 Subject: [PATCH 1/2] Protected members are available only via getters. --- .../Bundle/PimcoreBundle/CoreExtension/EmbeddedClass.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/CoreShop/Bundle/PimcoreBundle/CoreExtension/EmbeddedClass.php b/src/CoreShop/Bundle/PimcoreBundle/CoreExtension/EmbeddedClass.php index 855dfd0aeb..e14557c76d 100644 --- a/src/CoreShop/Bundle/PimcoreBundle/CoreExtension/EmbeddedClass.php +++ b/src/CoreShop/Bundle/PimcoreBundle/CoreExtension/EmbeddedClass.php @@ -57,6 +57,7 @@ public function getDataForEditmode($data, $object = null, $params = []) $returnData = []; + $i = 0; foreach ($data as $embeddedObject) { if (!$embeddedObject instanceof DataObject\Concrete) { continue; @@ -72,12 +73,12 @@ public function getDataForEditmode($data, $object = null, $params = []) list('objectData' => $objectData['data'], 'metaData' => $objectData['metaData']) = $editmodeHelper->getDataForObject($embeddedObject); $objectData['id'] = $embeddedObject->getId(); + $allowedKeys = ['o_published', 'o_key', 'o_id', 'o_modificationDate', 'o_creationDate', 'o_classId', 'o_locked', 'o_type', 'o_parentId', 'o_userOwner', 'o_userModification']; + $objectData['general'] = [ - 'index' => $embeddedObject->getIndex(), + 'o_className' => $embeddedObject->getClassName(), + 'index' => ++$i ]; - - $allowedKeys = ['o_published', 'o_key', 'o_id', 'o_modificationDate', 'o_creationDate', 'o_classId', 'o_className', 'o_locked', 'o_type', 'o_parentId', 'o_userOwner', 'o_userModification']; - foreach (get_object_vars($embeddedObject) as $key => $value) { if (strstr($key, 'o_') && in_array($key, $allowedKeys)) { $objectData['general'][$key] = $value; From a1a9b05cb2552e7118484bde2c30bf5fdf83e7f9 Mon Sep 17 00:00:00 2001 From: Rishad Omar Date: Fri, 6 Sep 2019 09:27:19 +0200 Subject: [PATCH 2/2] Call all members via getters (including the public members) --- .../CoreExtension/EmbeddedClass.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/CoreShop/Bundle/PimcoreBundle/CoreExtension/EmbeddedClass.php b/src/CoreShop/Bundle/PimcoreBundle/CoreExtension/EmbeddedClass.php index e14557c76d..c78cf43420 100644 --- a/src/CoreShop/Bundle/PimcoreBundle/CoreExtension/EmbeddedClass.php +++ b/src/CoreShop/Bundle/PimcoreBundle/CoreExtension/EmbeddedClass.php @@ -73,17 +73,21 @@ public function getDataForEditmode($data, $object = null, $params = []) list('objectData' => $objectData['data'], 'metaData' => $objectData['metaData']) = $editmodeHelper->getDataForObject($embeddedObject); $objectData['id'] = $embeddedObject->getId(); - $allowedKeys = ['o_published', 'o_key', 'o_id', 'o_modificationDate', 'o_creationDate', 'o_classId', 'o_locked', 'o_type', 'o_parentId', 'o_userOwner', 'o_userModification']; - $objectData['general'] = [ + 'index' => ++$i, + 'o_published' => $embeddedObject->getPublished(), + 'o_key' => $embeddedObject->getKey(), + 'o_id' => $embeddedObject->getId(), + 'o_modificationDate' => $embeddedObject->getModificationDate(), + 'o_creationDate' => $embeddedObject->getCreationDate(), + 'o_classId' => $embeddedObject->getClassId(), 'o_className' => $embeddedObject->getClassName(), - 'index' => ++$i + 'o_locked' => $embeddedObject->getLocked(), + 'o_type' => $embeddedObject->getType(), + 'o_parentId' => $embeddedObject->getParentId(), + 'o_userOwner' => $embeddedObject->getUserOwner(), + 'o_userModification' => $embeddedObject->getUserModification() ]; - foreach (get_object_vars($embeddedObject) as $key => $value) { - if (strstr($key, 'o_') && in_array($key, $allowedKeys)) { - $objectData['general'][$key] = $value; - } - } $returnData[] = $objectData; }