Skip to content

Commit

Permalink
Fixed an issue with grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
kisztof committed Jul 18, 2023
1 parent 4375c0d commit ac18a71
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/Repository/NameSchema/SchemaIdentifierExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class SchemaIdentifierExtractor implements SchemaIdentifierExtractorInterf
*/
public function extract(string $schemaString): array
{
$allTokens = '/<([^>]+)>/';
$allTokens = '/<([^>-]+)>/';

if (false === preg_match_all($allTokens, $schemaString, $matches)) {
return [];
Expand All @@ -36,7 +36,6 @@ public function extract(string $schemaString): array
$strategyIdentifiers = [];
foreach ($matches[1] as $tokenExpression) {
$tokens = explode('|', $tokenExpression);

foreach ($tokens as $token) {
$strategyToken = explode(':', $token, 2);

Expand All @@ -47,8 +46,11 @@ public function extract(string $schemaString): array
$strategy = 'field';
}

$token = preg_replace('/[()<>\[\]]/', '', $token);
$strategyIdentifiers[$strategy][] = $token;
}

$strategyIdentifiers[$strategy] = array_unique($strategyIdentifiers[$strategy]);
}

return $strategyIdentifiers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ public function getDataForTestExtract(): iterable
'field' => ['bar', 'baz'],
],
];

$schemaString = '<specification|(<name> <image1>)-<custom:bar|baz>-<field:bar|baz>';
yield $schemaString => [
$schemaString,
[
'field' => ['specification', 'name', 'image1', 'baz', 'bar'],
'custom' => ['bar'],
],
];
}

protected function setUp(): void
Expand Down

0 comments on commit ac18a71

Please sign in to comment.