From 4d173c762c8776906cf29013f90afb7bc3e1450d Mon Sep 17 00:00:00 2001 From: ctippler Date: Fri, 22 Mar 2024 09:20:08 +0100 Subject: [PATCH 1/4] Add a getter to be able to get the attribute (#116) * Add a getter to be able to the attribute * Apply php-cs-fixer changes --------- Co-authored-by: ctippler --- src/ConfigElement/AbstractConfigElement.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ConfigElement/AbstractConfigElement.php b/src/ConfigElement/AbstractConfigElement.php index 49960d4..6e53a35 100644 --- a/src/ConfigElement/AbstractConfigElement.php +++ b/src/ConfigElement/AbstractConfigElement.php @@ -34,4 +34,9 @@ public function getLabel() { return $this->label; } + + public function getAttribute() + { + return $this->attribute; + } } From 957eeac13f6a115da23a71a8ca130071b624407a Mon Sep 17 00:00:00 2001 From: ctippler Date: Fri, 22 Mar 2024 09:25:07 +0100 Subject: [PATCH 2/4] Allow customizations (#114) * - Make also "Value" Classes extendable (same logic as for operators) - move logic for classification store getter to own method to make it easier to overwrite - Fix logic vor class loading (first check app specific folders - then the the regular one) * Apply php-cs-fixer changes --------- Co-authored-by: ctippler --- src/ConfigElement/Value/DefaultValue.php | 73 +++++++++++++----------- src/Service.php | 12 ++-- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/src/ConfigElement/Value/DefaultValue.php b/src/ConfigElement/Value/DefaultValue.php index 9cd501e..d7d5eae 100644 --- a/src/ConfigElement/Value/DefaultValue.php +++ b/src/ConfigElement/Value/DefaultValue.php @@ -77,40 +77,7 @@ public function getLabeledValue($object) $brickGetter = 'get' . ucfirst($brickKey); } } elseif (substr($this->attribute, 0, 4) == '#cs#') { - // checking classification store fieldname - if (!$this->classificationstore) { - return null; - } - $getter = 'get' . ucfirst($this->classificationstore); - // checking classification sote group - if (!$this->classificationstore_group) { - return null; - } - $groupDef = Classificationstore\GroupConfig::getByName($this->classificationstore_group); - - // classification store - $attribute = str_replace('#cs#', '', $this->attribute); - list($keyId) = explode('#', $attribute); - - $value = $object->$getter()->getLocalizedKeyValue($groupDef->getId(), $keyId); - - $result = new \stdClass(); - $result->value = $value; - $result->label = $this->label; - $result->attribute = $this->attribute; - - $config = Classificationstore\KeyConfig::getById((int) $keyId); - if ($config) { - $result->def = Classificationstore\Service::getFieldDefinitionFromKeyConfig($config); - } - - if (empty($value) || (is_object($value) && method_exists($value, 'isEmpty') && $value->isEmpty())) { - $result->empty = true; - } else { - $result->empty = false; - } - - return $result; + return $this->getLabeledValueForClassificationStore($object); } if (method_exists($object, $getter) || (class_exists(DefaultMockup::class) && $object instanceof DefaultMockup)) { @@ -186,4 +153,42 @@ public function getLabeledValue($object) return null; } + + protected function getLabeledValueForClassificationStore($object): ?object + { + // checking classification store fieldname + if (!$this->classificationstore) { + return null; + } + $getter = 'get' . ucfirst($this->classificationstore); + // checking classification sote group + if (!$this->classificationstore_group) { + return null; + } + $groupDef = Classificationstore\GroupConfig::getByName($this->classificationstore_group); + + // classification store + $attribute = str_replace('#cs#', '', $this->attribute); + list($keyId) = explode('#', $attribute); + + $value = $object->$getter()->getLocalizedKeyValue($groupDef->getId(), $keyId); + + $result = new \stdClass(); + $result->value = $value; + $result->label = $this->label; + $result->attribute = $this->attribute; + + $config = Classificationstore\KeyConfig::getById((int) $keyId); + if ($config) { + $result->def = Classificationstore\Service::getFieldDefinitionFromKeyConfig($config); + } + + if (empty($value) || (is_object($value) && method_exists($value, 'isEmpty') && $value->isEmpty())) { + $result->empty = true; + } else { + $result->empty = false; + } + + return $result; + } } diff --git a/src/Service.php b/src/Service.php index 0eeda5b..b1b4f96 100644 --- a/src/Service.php +++ b/src/Service.php @@ -67,12 +67,12 @@ public static function buildOutputDataConfig($outputDataConfig, $context = null) return self::doBuildConfig($jsonConfig, $config, $context); } - private static function locateOperatorConfigClass($configElement): string + private static function locateConfigClass(string $type, $configElement): string { $namespaces = [ - '\\OutputDataConfigToolkitBundle\\ConfigElement\\Operator\\', - '\\App\\OutputDataConfigToolkit\\ConfigElement\\Operator\\', - '\\AppBundle\\OutputDataConfigToolkit\\ConfigElement\\Operator\\' + '\\AppBundle\\OutputDataConfigToolkit\\ConfigElement\\' . $type . '\\', + '\\App\\OutputDataConfigToolkit\\ConfigElement\\' . $type . '\\', + '\\OutputDataConfigToolkitBundle\\ConfigElement\\' . $type . '\\', ]; foreach ($namespaces as $namespace) { @@ -90,13 +90,13 @@ private static function doBuildConfig($jsonConfig, $config, $context = null) if (!empty($jsonConfig)) { foreach ($jsonConfig as $configElement) { if ($configElement->type == 'value') { - $name = '\\OutputDataConfigToolkitBundle\\ConfigElement\\Value\\' . ucfirst($configElement->class); + $name = self::locateConfigClass('Value', $configElement); if (class_exists($name)) { $config[] = new $name($configElement, $context); } } elseif ($configElement->type == 'operator') { - $className = self::locateOperatorConfigClass($configElement); + $className = self::locateConfigClass('Operator', $configElement); if (!empty($configElement->childs)) { $configElement->childs = self::doBuildConfig($configElement->childs, [], $context); } From e08489bd8632d0017982ec249d8447ef6e0c4c18 Mon Sep 17 00:00:00 2001 From: Vladimir Malik Date: Fri, 22 Mar 2024 09:32:00 +0100 Subject: [PATCH 3/4] Remove icon from field dialog (#111) --- src/Resources/public/js/OutputDataConfigDialog.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Resources/public/js/OutputDataConfigDialog.js b/src/Resources/public/js/OutputDataConfigDialog.js index 5d2a665..001495f 100644 --- a/src/Resources/public/js/OutputDataConfigDialog.js +++ b/src/Resources/public/js/OutputDataConfigDialog.js @@ -46,7 +46,6 @@ pimcore.bundle.outputDataConfigToolkit.OutputDataConfigDialog = Class.create(pim width: 850, height: 650, modal: true, - iconCls: "bundle_outputdataconfig_icon", title: t('output_channel_definition_for') + " " + t(this.outputConfig.channel), layout: "fit", items: [this.configPanel] From 34e51ce9514ecda7ccc65aafcb9dbe4ab57c8c34 Mon Sep 17 00:00:00 2001 From: markus-moser Date: Fri, 5 Apr 2024 09:57:05 +0200 Subject: [PATCH 4/4] Update CLA check --- .github/workflows/cla-check.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/cla-check.yaml diff --git a/.github/workflows/cla-check.yaml b/.github/workflows/cla-check.yaml new file mode 100644 index 0000000..2c7cc9d --- /dev/null +++ b/.github/workflows/cla-check.yaml @@ -0,0 +1,14 @@ +name: CLA check + +on: + issue_comment: + types: [created] + pull_request_target: + types: [opened, closed, synchronize] + +jobs: + cla-workflow: + uses: pimcore/workflows-collection-public/.github/workflows/reusable-cla-check.yaml@v1.3.0 + if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' + secrets: + CLA_ACTION_ACCESS_TOKEN: ${{ secrets.CLA_ACTION_ACCESS_TOKEN }}