Skip to content

Commit dc19309

Browse files
authored
Fix L8 cached routes (#29)
* Fix L8 cached routes This will fix the following error when using cached routes without the $namespace member in your RouteServiceProvider: ``` Argument 1 passed to CodeZero\LocalizedRoutes\UrlGenerator::__construct() must be an instance of Illuminate\Routing\RouteCollection, instance of Illuminate\Routing\CompiledRouteCollection given, called in /var/www/vendor/codezero/laravel-localized-routes/src/LocalizedRoutesServiceProvider.php on line 104 ``` * Remove incompatible dependencies, Remove tests for deprecated versions, * Remove function type hint, check type manually, Add back support & testing for L5.6+, * Fix code standard * Update condition
1 parent 70a0964 commit dc19309

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"illuminate/support": "^5.6|^6.0|^7.0|^8.0"
2727
},
2828
"require-dev": {
29-
"mockery/mockery": "^1.3",
29+
"mockery/mockery": "^1.0",
3030
"orchestra/testbench": "^3.6|^4.0|^5.0|^6.0",
3131
"phpunit/phpunit": "^7.0|^8.0|^9.0"
3232
},

src/UrlGenerator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ class UrlGenerator extends BaseUrlGenerator
1818
* @param \Illuminate\Http\Request $request
1919
* @param string $assetRoot
2020
*/
21-
public function __construct(RouteCollection $routes, Request $request, $assetRoot = null)
21+
public function __construct($routes, Request $request, $assetRoot = null)
2222
{
23+
if (!$routes instanceof RouteCollection && !(class_exists('Illuminate\Routing\RouteCollectionInterface') && is_subclass_of($routes, 'Illuminate\Routing\RouteCollectionInterface'))) {
24+
throw new \InvalidArgumentException('The $routes parameter has to be of type RouteCollection or RouteCollectionInterface for L6+.');
25+
}
26+
2327
parent::__construct($routes, $request, $assetRoot);
2428
}
2529

0 commit comments

Comments
 (0)