Skip to content

Commit 47bb485

Browse files
committed
boot method of a ServiceProvided gets an instance of Laravel\Lumen\Application.
A second argument is not provided. In `Laravel\Lumen\Application` method to assign a short-hand key for middleware is called `routeMiddleware`.
1 parent 90ff187 commit 47bb485

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/ServiceProvider.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@
4141
use CloudCreativity\LaravelJsonApi\Http\Responses\Responses;
4242
use CloudCreativity\LaravelJsonApi\Services\JsonApiService;
4343
use CloudCreativity\LaravelJsonApi\Validators\ValidatorErrorFactory;
44-
use Illuminate\Contracts\Foundation\Application;
4544
use Illuminate\Contracts\Routing\ResponseFactory as ResponseFactoryContract;
46-
use Illuminate\Routing\Router;
4745
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
46+
use Laravel\Lumen\Application;
4847
use Neomerx\JsonApi\Contracts\Document\DocumentFactoryInterface;
4948
use Neomerx\JsonApi\Contracts\Encoder\Handlers\HandlerFactoryInterface;
5049
use Neomerx\JsonApi\Contracts\Encoder\Parser\ParserFactoryInterface;
@@ -85,11 +84,9 @@ class ServiceProvider extends BaseServiceProvider
8584
* @param ResponseFactoryContract $responses
8685
*/
8786
public function boot(
88-
Router $router,
89-
ResponseFactoryContract $responses
87+
Application $router
9088
) {
9189
$this->bootMiddleware($router);
92-
$this->bootResponseMacro($responses);
9390
}
9491

9592
/**
@@ -116,13 +113,20 @@ public function register()
116113
*
117114
* @param Router $router
118115
*/
119-
protected function bootMiddleware(Router $router)
116+
protected function bootMiddleware(Application $router)
120117
{
121118
/** Laravel 5.4 */
122119
if (method_exists($router, 'aliasMiddleware')) {
123120
$router->aliasMiddleware('json-api', BootJsonApi::class);
124121
$router->aliasMiddleware('json-api.authorize', AuthorizeRequest::class);
125122
$router->aliasMiddleware('json-api.validate', ValidateRequest::class);
123+
} /** Lumen **/
124+
else if (method_exists($router, 'routeMiddleware')) {
125+
$router->routeMiddleware([
126+
'json-api' => BootJsonApi::class,
127+
'json-api.authorize' => AuthorizeRequest::class,
128+
'json-api.validate' => ValidateRequest::class,
129+
]);
126130
} /** Laravel 5.1|5.2|5.3 */
127131
else {
128132
$router->middleware('json-api', BootJsonApi::class);

0 commit comments

Comments
 (0)