@@ -158,8 +158,15 @@ protected function bootPublishing()
158
158
*/
159
159
protected function bootMiddleware (Router $ router )
160
160
{
161
- $ router ->middleware ('json-api ' , BootJsonApi::class);
162
- $ router ->middleware ('json-api.request ' , HandleRequest::class);
161
+ /** Laravel 5.4 */
162
+ if (method_exists ($ router , 'aliasMiddleware ' )) {
163
+ $ router ->aliasMiddleware ('json-api ' , BootJsonApi::class);
164
+ $ router ->aliasMiddleware ('json-api.request ' , HandleRequest::class);
165
+ } /** Laravel 5.1|5.2|5.3 */
166
+ else {
167
+ $ router ->middleware ('json-api ' , BootJsonApi::class);
168
+ $ router ->middleware ('json-api.request ' , HandleRequest::class);
169
+ }
163
170
}
164
171
165
172
/**
@@ -282,29 +289,32 @@ protected function bindErrorRepository()
282
289
{
283
290
$ this ->app ->singleton (ReplacerInterface::class, Replacer::class);
284
291
285
- $ this ->app ->singleton ([ ' json-api.errors ' => ErrorRepositoryInterface::class] , function () {
292
+ $ this ->app ->singleton (ErrorRepositoryInterface::class, function () {
286
293
/** @var ReplacerInterface $replacer */
287
294
$ replacer = $ this ->app ->make (ReplacerInterface::class);
288
295
$ repository = new ErrorRepository ($ replacer );
289
296
$ repository ->configure ($ this ->getErrorConfig ());
290
297
return $ repository ;
291
298
});
299
+ $ this ->app ->alias (ErrorRepositoryInterface::class, 'json-api.errors ' );
292
300
}
293
301
294
302
/**
295
303
* Bind the exception parser into the service container.
296
304
*/
297
305
protected function bindExceptionParser ()
298
306
{
299
- $ this ->app ->singleton (['json-api.exceptions ' => ExceptionParserInterface::class], ExceptionParser::class);
307
+ $ this ->app ->singleton (ExceptionParserInterface::class, ExceptionParser::class);
308
+ $ this ->app ->alias (ExceptionParserInterface::class, 'json-api.exceptions ' );
300
309
}
301
310
302
311
/**
303
312
* Bind the store into the service container.
304
313
*/
305
314
protected function bindStore ()
306
315
{
307
- $ this ->app ->singleton (['json-api.store ' => StoreInterface::class], Store::class);
316
+ $ this ->app ->singleton (StoreInterface::class, Store::class);
317
+ $ this ->app ->alias (StoreInterface::class, 'json-api.store ' );
308
318
}
309
319
310
320
/**
@@ -341,7 +351,8 @@ protected function bindStoreAdapters()
341
351
*/
342
352
protected function bindLinkFactory ()
343
353
{
344
- $ this ->app ->singleton (['json-api.links ' => LinkFactoryInterface::class], LinkFactory::class);
354
+ $ this ->app ->singleton (LinkFactoryInterface::class, LinkFactory::class);
355
+ $ this ->app ->alias (LinkFactoryInterface::class, 'json-api.links ' );
345
356
}
346
357
347
358
/**
0 commit comments