Skip to content

Commit

Permalink
Fix: Labels get lowercased (#853)
Browse files Browse the repository at this point in the history
* Fix: Labels get lowercased

* Fix: Labels get lowercased

* Enrich php doc
  • Loading branch information
blankse authored May 17, 2024
1 parent 503e028 commit 053f11f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
17 changes: 13 additions & 4 deletions src/GraphQL/DataObjectQueryOperatorConfigGenerator/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ public function getGraphQlType($typeName, $nodeDef, $class = null, $container =
public function getGraphQlQueryOperatorConfig($typeName, $nodeDef, $class = null, $container = null, $params = [])
{
$attributes = $nodeDef['attributes'];
$label = (isset($attributes['label']) ? $attributes['label'] : '#' . uniqid());
$label = lcfirst($label);
$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 @@ -105,4 +102,16 @@ public function getFieldType($attributes, $class = null, $container = null)
{
return Type::string();
}

/**
* @param array{label?: string} $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 053f11f

Please sign in to comment.