Skip to content

Commit

Permalink
Fix: Labels get lowercased
Browse files Browse the repository at this point in the history
  • Loading branch information
blankse committed Apr 23, 2024
1 parent 1647440 commit 68f11c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
16 changes: 13 additions & 3 deletions src/GraphQL/DataObjectQueryOperatorConfigGenerator/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ public function getGraphQlType($typeName, $nodeDef, $class = null, $container =
public function getGraphQlQueryOperatorConfig($typeName, $nodeDef, $class = null, $container = null, $params = [])
{
$attributes = $nodeDef['attributes'];
$label = $attributes['label'] ?? '#' . uniqid();
$fieldname = preg_replace('/[^A-Za-z0-9\-\.~_]+/', '_', $label);

$fieldname = $this->getFieldname($attributes);
$type = $this->getGraphQlType($typeName, $nodeDef, $class, $container, $params);

$resolver = new \Pimcore\Bundle\DataHubBundle\GraphQL\Resolver\Base($typeName, $attributes, $class, $container);
Expand Down Expand Up @@ -104,4 +102,16 @@ public function getFieldType($attributes, $class = null, $container = null)
{
return Type::string();
}

/**
* @param array $attributes
*
* @return string|null
*/
protected function getFieldname($attributes)
{
$label = $attributes['label'] ?? '#' . uniqid();

return preg_replace('/[^A-Za-z0-9\-\.~_]+/', '_', $label);
}
}
14 changes: 0 additions & 14 deletions src/GraphQL/DataObjectQueryOperatorConfigGenerator/Merge.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@
*/
class Merge extends StringBase
{
/**
* @param array $attributes
*
* @return array|string|string[]|null
*/
protected function getFieldname($attributes)
{
$label = ($attributes['label'] ? $attributes['label'] : '#'.uniqid());
$label = lcfirst($label);
$fieldname = preg_replace('/[^A-Za-z0-9\-\.~_]+/', '_', $label);

return $fieldname;
}

/**
* @param string $typeName
* @param array $nodeConfig
Expand Down

0 comments on commit 68f11c7

Please sign in to comment.