Skip to content

Commit

Permalink
Merge branch '5.x' into fix-outputchannels-with-classification-store
Browse files Browse the repository at this point in the history
  • Loading branch information
aweichler committed Apr 17, 2024
2 parents 6989acf + a50eeca commit 3db004f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 41 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/cla-check.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}
5 changes: 5 additions & 0 deletions src/ConfigElement/AbstractConfigElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ public function setClassificationstoreGroup(?string $classificationstore_group):
{
$this->classificationstore_group = $classificationstore_group;
}

public function getAttribute()
{
return $this->attribute;
}
}
73 changes: 39 additions & 34 deletions src/ConfigElement/Value/DefaultValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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->getClassificationstore()) {
return null;
}
$getter = 'get' . ucfirst($this->getClassificationstore());
// checking classification sote group
if (!$this->getClassificationstoreGroup()) {
return null;
}
$groupDef = Classificationstore\GroupConfig::getByName($this->getClassificationstoreGroup());

// 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)) {
Expand Down Expand Up @@ -186,4 +153,42 @@ public function getLabeledValue($object)

return null;
}

protected function getLabeledValueForClassificationStore($object): ?object
{
// checking classification store fieldname
if (!$this->getClassificationstore()) {
return null;
}
$getter = 'get' . ucfirst($this->getClassificationstore());
// checking classification sote group
if (!$this->getClassificationstoreGroup()) {
return null;
}
$groupDef = Classificationstore\GroupConfig::getByName($this->getClassificationstoreGroup());

// 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;
}
}
1 change: 0 additions & 1 deletion src/Resources/public/js/OutputDataConfigDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
12 changes: 6 additions & 6 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down

0 comments on commit 3db004f

Please sign in to comment.