| @@ 316-347 (lines=32) @@ | ||
| 313 | return; |
|
| 314 | } |
|
| 315 | ||
| 316 | foreach ($routes as $uri => $route) { |
|
| 317 | ||
| 318 | /* |
|
| 319 | * If the route definition is an |
|
| 320 | * not an array then let's make it one. |
|
| 321 | * Array type routes give us more control |
|
| 322 | * and allow us to pass information in the |
|
| 323 | * request's route action array. |
|
| 324 | */ |
|
| 325 | if (!is_array($route)) { |
|
| 326 | $route = [ |
|
| 327 | 'uses' => $route, |
|
| 328 | ]; |
|
| 329 | } |
|
| 330 | ||
| 331 | $verb = array_pull($route, 'verb', 'any'); |
|
| 332 | $middleware = array_pull($route, 'middleware', []); |
|
| 333 | $constraints = array_pull($route, 'constraints', []); |
|
| 334 | ||
| 335 | array_set($route, 'streams::addon', $addon->getNamespace()); |
|
| 336 | ||
| 337 | if (is_string($route['uses']) && !str_contains($route['uses'], '@')) { |
|
| 338 | $this->router->resource($uri, $route['uses']); |
|
| 339 | } else { |
|
| 340 | ||
| 341 | $route = $this->router->{$verb}($uri, $route)->where($constraints); |
|
| 342 | ||
| 343 | if ($middleware) { |
|
| 344 | call_user_func_array([$route, 'middleware'], (array)$middleware); |
|
| 345 | } |
|
| 346 | } |
|
| 347 | } |
|
| 348 | } |
|
| 349 | ||
| 350 | /** |
|
| @@ 444-475 (lines=32) @@ | ||
| 441 | ], |
|
| 442 | ]; |
|
| 443 | ||
| 444 | foreach ($routes as $uri => $route) { |
|
| 445 | ||
| 446 | /* |
|
| 447 | * If the route definition is an |
|
| 448 | * not an array then let's make it one. |
|
| 449 | * Array type routes give us more control |
|
| 450 | * and allow us to pass information in the |
|
| 451 | * request's route action array. |
|
| 452 | */ |
|
| 453 | if (!is_array($route)) { |
|
| 454 | $route = [ |
|
| 455 | 'uses' => $route, |
|
| 456 | ]; |
|
| 457 | } |
|
| 458 | ||
| 459 | $verb = array_pull($route, 'verb', 'any'); |
|
| 460 | $middleware = array_pull($route, 'middleware', []); |
|
| 461 | $constraints = array_pull($route, 'constraints', []); |
|
| 462 | ||
| 463 | array_set($route, 'streams::addon', $addon->getNamespace()); |
|
| 464 | ||
| 465 | if (is_string($route['uses']) && !str_contains($route['uses'], '@')) { |
|
| 466 | $this->router->resource($uri, $route['uses']); |
|
| 467 | } else { |
|
| 468 | ||
| 469 | $route = $this->router->{$verb}($uri, $route)->where($constraints); |
|
| 470 | ||
| 471 | if ($middleware) { |
|
| 472 | call_user_func_array([$route, 'middleware'], (array)$middleware); |
|
| 473 | } |
|
| 474 | } |
|
| 475 | } |
|
| 476 | } |
|
| 477 | ||
| 478 | /** |
|