diff --git a/src/Auth/BasicProvider.php b/src/Auth/BasicProvider.php index af727b136..364bd92f5 100644 --- a/src/Auth/BasicProvider.php +++ b/src/Auth/BasicProvider.php @@ -39,6 +39,7 @@ public function __construct(AuthManager $auth, $identifier = 'email') * @param \Illuminate\Http\Request $request * @param \Illuminate\Routing\Route $route * @return int + * @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException */ public function authenticate(Request $request, Route $route) { diff --git a/src/Auth/DingoOAuth2Provider.php b/src/Auth/DingoOAuth2Provider.php index b1324043c..87e467f40 100644 --- a/src/Auth/DingoOAuth2Provider.php +++ b/src/Auth/DingoOAuth2Provider.php @@ -33,6 +33,8 @@ public function __construct(Resource $resource) * @param \Illuminate\Http\Request $request * @param \Illuminate\Routing\Route $route * @return int + * @throws \Exception when header authorization fails. + * @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException when invalid token exception is called inside token validator. */ public function authenticate(Request $request, Route $route) { diff --git a/src/Auth/LeagueOAuth2Provider.php b/src/Auth/LeagueOAuth2Provider.php index ed6783d3b..95f26370a 100644 --- a/src/Auth/LeagueOAuth2Provider.php +++ b/src/Auth/LeagueOAuth2Provider.php @@ -42,6 +42,8 @@ public function __construct(Resource $resource, $httpHeadersOnly = false) * @param \Illuminate\Http\Request $request * @param \Illuminate\Routing\Route $route * @return int + * @throws \Exception + * @throws \Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException */ public function authenticate(Request $request, Route $route) { diff --git a/src/Auth/Shield.php b/src/Auth/Shield.php index b305c1127..84fd150c2 100644 --- a/src/Auth/Shield.php +++ b/src/Auth/Shield.php @@ -74,6 +74,7 @@ public function __construct(AuthManager $auth, Container $container, array $prov * Authenticate the current request. * * @return null|\Dingo\Api\Http\Response + * @throws \Exception */ public function authenticate(Request $request, Route $route) { diff --git a/src/Pagination/IlluminatePaginatorWrapper.php b/src/Pagination/IlluminatePaginatorWrapper.php new file mode 100644 index 000000000..befa15ac1 --- /dev/null +++ b/src/Pagination/IlluminatePaginatorWrapper.php @@ -0,0 +1,85 @@ +paginator = $paginator; + } + + /** + * {@inheritDoc} + */ + public function getCurrentPage() + { + return $this->paginator->getCurrentPage(); + } + + /** + * {@inheritDoc} + */ + public function getLastPage() + { + return $this->paginator->getLastPage(); + } + + /** + * {@inheritDoc} + */ + public function getTotal() + { + return $this->paginator->getTotal(); + } + + /** + * {@inheritDoc} + */ + public function count() + { + return $this->paginator->count(); + } + + /** + * {@inheritDoc} + */ + public function getPerPage() + { + return $this->paginator->getPerPage(); + } + + /** + * {@inheritDoc} + */ + public function getUrl($page) + { + return $this->paginator->getUrl($page); + } + + /** + * @param string $method + * @param array $args + * @throws \BadMethodCallException + */ + public function __call($method, $args) + { + if (! method_exists($this->paginator, $method)) + { + throw new \BadMethodCallException("Unable to find method {$method} on paginator instance."); + } + + return call_user_func_array([$this->paginator, $method], $args); + } + +} diff --git a/src/Routing/Router.php b/src/Routing/Router.php index fd7515779..888506d42 100644 --- a/src/Routing/Router.php +++ b/src/Routing/Router.php @@ -97,6 +97,7 @@ class Router extends IlluminateRouter { * @param array $options * @param callable $callback * @return void + * @throws \BadMethodCallException when api version not specified. */ public function api($options, callable $callback) { @@ -136,6 +137,7 @@ public function api($options, callable $callback) * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response|\Dingo\Api\Http\Response + * @throws \HttpExceptionInterface */ public function dispatch(Request $request) { diff --git a/src/Transformer/FractalTransformer.php b/src/Transformer/FractalTransformer.php index 0469f020b..b365b6e36 100644 --- a/src/Transformer/FractalTransformer.php +++ b/src/Transformer/FractalTransformer.php @@ -2,7 +2,7 @@ use League\Fractal\Manager as Fractal; use League\Fractal\Resource\Item as FractalItem; -use League\Fractal\Pagination\IlluminatePaginatorAdapter; +use Dingo\Api\Pagination\IlluminatePaginatorWrapper; use Illuminate\Support\Collection as IlluminateCollection; use Illuminate\Pagination\Paginator as IlluminatePaginator; use League\Fractal\Resource\Collection as FractalCollection; @@ -63,7 +63,7 @@ public function transformResponse($response, $transformer) // collection resource. if ($response instanceof IlluminatePaginator) { - $paginator = new IlluminatePaginatorAdapter($response); + $paginator = new IlluminatePaginatorWrapper($response); $resource->setPaginator($paginator); }