Skip to content

Commit

Permalink
boot method of a ServiceProvided gets an instance of Laravel\Lume…
Browse files Browse the repository at this point in the history
…n\Application.

A second argument is not provided.

In `Laravel\Lumen\Application` method to assign a short-hand key for
middleware is called `routeMiddleware`.
  • Loading branch information
jelhan committed May 24, 2017
1 parent 90ff187 commit 47bb485
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@
use CloudCreativity\LaravelJsonApi\Http\Responses\Responses;
use CloudCreativity\LaravelJsonApi\Services\JsonApiService;
use CloudCreativity\LaravelJsonApi\Validators\ValidatorErrorFactory;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory as ResponseFactoryContract;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use Laravel\Lumen\Application;
use Neomerx\JsonApi\Contracts\Document\DocumentFactoryInterface;
use Neomerx\JsonApi\Contracts\Encoder\Handlers\HandlerFactoryInterface;
use Neomerx\JsonApi\Contracts\Encoder\Parser\ParserFactoryInterface;
Expand Down Expand Up @@ -85,11 +84,9 @@ class ServiceProvider extends BaseServiceProvider
* @param ResponseFactoryContract $responses
*/
public function boot(
Router $router,
ResponseFactoryContract $responses
Application $router
) {
$this->bootMiddleware($router);
$this->bootResponseMacro($responses);
}

/**
Expand All @@ -116,13 +113,20 @@ public function register()
*
* @param Router $router
*/
protected function bootMiddleware(Router $router)
protected function bootMiddleware(Application $router)
{
/** Laravel 5.4 */
if (method_exists($router, 'aliasMiddleware')) {
$router->aliasMiddleware('json-api', BootJsonApi::class);
$router->aliasMiddleware('json-api.authorize', AuthorizeRequest::class);
$router->aliasMiddleware('json-api.validate', ValidateRequest::class);
} /** Lumen **/
else if (method_exists($router, 'routeMiddleware')) {
$router->routeMiddleware([
'json-api' => BootJsonApi::class,
'json-api.authorize' => AuthorizeRequest::class,
'json-api.validate' => ValidateRequest::class,
]);
} /** Laravel 5.1|5.2|5.3 */
else {
$router->middleware('json-api', BootJsonApi::class);
Expand Down

0 comments on commit 47bb485

Please sign in to comment.