diff options
| author | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:32 +0100 |
|---|---|---|
| committer | Sam Light <sam@lightscale.co.uk> | 2026-06-10 19:00:32 +0100 |
| commit | a61bcc830dfe801db7f94e01bbbe5a0b7b0a7dea (patch) | |
| tree | 6b8aaa7b06b6c4f442dd0d46255608b34b82a7a0 /src/Group.php | |
| parent | 6ad39e3ba64e518bcdba1fc32b6247375be39a8a (diff) | |
getting parents and path from group and testing
Diffstat (limited to 'src/Group.php')
| -rw-r--r-- | src/Group.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Group.php b/src/Group.php index 4e6c71e..c208180 100644 --- a/src/Group.php +++ b/src/Group.php @@ -21,7 +21,7 @@ class Group return $this->router; } - public function getParent(): ?static + public function getParent(): ?self { return $this->parent; } @@ -40,7 +40,16 @@ class Group public function getPath(): string { + $ancestors = $this->getAncestorsAndSelf(); + return '/' . implode('/', array_filter( + array_map(fn(Group $g): ?string => ( + ($v = $g->getPrefix()) === null ? + null : + trim($v, '/') + ), $ancestors), + fn (?string $v) => $v !== null + )); } public function name(string $value): static @@ -55,7 +64,7 @@ class Group return $this->name; } - /** @param callable(self): void $cb */ + /** @param callable(GroupDefinition): void $cb */ public function group(callable $cb): void { ($cb)(new GroupDefinition( |
