Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/JsonForms/ScopePointer.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,24 @@ public function getPath(): array {
* @return array<string|int>
*/
public function getPropertyPath(): array {
return array_values(array_filter($this->getPath(), fn ($value) => 'properties' !== $value && '' !== $value));
$consecutivePropertiesCount = 0;
return array_values(array_filter(
$this->getPath(),
function ($value) use (&$consecutivePropertiesCount) {
// There might be a property named "properties" and the corresponding
// scope would contain ".../properties/properties/...". Thus, we cannot
// just filter out every occurrence of "properties".
if ('properties' === $value) {
$consecutivePropertiesCount++;

return $consecutivePropertiesCount % 2 === 0;
}

$consecutivePropertiesCount = 0;

return '' !== $value;
}
));
}

public function getScope(): string {
Expand Down