|
7 | 7 | class RouteResource extends LoadableRoute implements IControllerRoute |
8 | 8 | { |
9 | 9 | protected array $urls = [ |
10 | | - 'index' => '', |
11 | | - 'create' => 'create', |
12 | | - 'store' => '', |
13 | | - 'show' => '', |
14 | | - 'edit' => 'edit', |
15 | | - 'update' => '', |
| 10 | + 'index' => '', |
| 11 | + 'create' => 'create', |
| 12 | + 'store' => '', |
| 13 | + 'show' => '', |
| 14 | + 'edit' => 'edit', |
| 15 | + 'update' => '', |
16 | 16 | 'destroy' => '', |
17 | 17 | ]; |
18 | 18 |
|
19 | 19 | protected array $methodNames = [ |
20 | | - 'index' => 'index', |
21 | | - 'create' => 'create', |
22 | | - 'store' => 'store', |
23 | | - 'show' => 'show', |
24 | | - 'edit' => 'edit', |
25 | | - 'update' => 'update', |
| 20 | + 'index' => 'index', |
| 21 | + 'create' => 'create', |
| 22 | + 'store' => 'store', |
| 23 | + 'show' => 'show', |
| 24 | + 'edit' => 'edit', |
| 25 | + 'update' => 'update', |
26 | 26 | 'destroy' => 'destroy', |
27 | 27 | ]; |
28 | 28 |
|
@@ -68,12 +68,15 @@ public function hasName(string $name): bool |
68 | 68 | */ |
69 | 69 | public function findUrl(?string $method = null, $parameters = null, ?string $name = null): string |
70 | 70 | { |
71 | | - $url = array_search($name, $this->names, true); |
72 | | - if ($url !== false) { |
73 | | - return rtrim($this->url . $this->urls[$url], '/') . '/'; |
| 71 | + $url = parent::findUrl($method, $parameters, $name); |
| 72 | + |
| 73 | + $action = array_search($name, $this->names, true); |
| 74 | + |
| 75 | + if ($action !== false) { |
| 76 | + return $url . $this->urls[$action]; |
74 | 77 | } |
75 | 78 |
|
76 | | - return $this->url; |
| 79 | + return $url; |
77 | 80 | } |
78 | 81 |
|
79 | 82 | protected function call($method): bool |
@@ -172,12 +175,12 @@ public function setName(string $name): ILoadableRoute |
172 | 175 | $this->name = $name; |
173 | 176 |
|
174 | 177 | $this->names = [ |
175 | | - 'index' => $this->name . '.index', |
176 | | - 'create' => $this->name . '.create', |
177 | | - 'store' => $this->name . '.store', |
178 | | - 'show' => $this->name . '.show', |
179 | | - 'edit' => $this->name . '.edit', |
180 | | - 'update' => $this->name . '.update', |
| 178 | + 'index' => $this->name . '.index', |
| 179 | + 'create' => $this->name . '.create', |
| 180 | + 'store' => $this->name . '.store', |
| 181 | + 'show' => $this->name . '.show', |
| 182 | + 'edit' => $this->name . '.edit', |
| 183 | + 'update' => $this->name . '.update', |
181 | 184 | 'destroy' => $this->name . '.destroy', |
182 | 185 | ]; |
183 | 186 |
|
|
0 commit comments