From 530397db007f3e03f4d994dcd2800087355b9fc9 Mon Sep 17 00:00:00 2001 From: aynsix Date: Wed, 4 Dec 2019 10:17:59 +0400 Subject: [PATCH] do no use header application/vnd.phraseanet.story-paginate --- .../Application/ApiApplicationLoader.php | 3 +-- .../Phrasea/Controller/Api/V1Controller.php | 18 ++++-------------- .../Phrasea/ControllerProvider/Api/V1.php | 2 -- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/lib/Alchemy/Phrasea/Application/ApiApplicationLoader.php b/lib/Alchemy/Phrasea/Application/ApiApplicationLoader.php index c2f1a4da3b..490554c95e 100644 --- a/lib/Alchemy/Phrasea/Application/ApiApplicationLoader.php +++ b/lib/Alchemy/Phrasea/Application/ApiApplicationLoader.php @@ -51,8 +51,7 @@ class ApiApplicationLoader extends BaseApplicationLoader ['application/json', 'application/yaml', 'text/yaml', 'text/javascript', 'application/javascript'], V1::$extendedContentTypes['json'], V1::$extendedContentTypes['jsonp'], - V1::$extendedContentTypes['yaml'], - [V1::HEADER_ACCEPT_STORY_PAGINATE] + V1::$extendedContentTypes['yaml'] ); $app['phraseanet.content-negotiation.custom_formats'] = [ diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php index dacb48f539..cb2523e1ae 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php @@ -1217,18 +1217,12 @@ class V1Controller extends Controller $fractal->setSerializer(new TraceableArraySerializer($this->app['dispatcher'])); $fractal->parseIncludes($this->resolveSearchIncludes($request)); - $story_max_items = null; - // if the header accept story paginate, take account story_max_items parameter - if (in_array(V1::HEADER_ACCEPT_STORY_PAGINATE, $request->getAcceptableContentTypes())) { - $story_max_items = (int)$request->get('story_max_items') ?: 10; - } - $result = $this->doSearch($request); $searchView = $this->buildSearchView( $result, $includeResolver->resolve($fractal), $this->resolveSubdefUrlTTL($request), - $story_max_items + (int)$request->get('story_max_items') ?: 10 ); $ret = $fractal->createData(new Item($searchView, $searchTransformer))->toArray(); @@ -1682,13 +1676,9 @@ class V1Controller extends Controller return Result::createError($request, 404, 'Story not found')->createResponse(); } - $offset = 1; - $max_items = null; - if (in_array(V1::HEADER_ACCEPT_STORY_PAGINATE, $request->getAcceptableContentTypes())) { - $max_items = (int)$request->get('max_items')?:10; - $page = (int)$request->get('page')?:1; - $offset = ($max_items * ($page - 1)) + 1; - } + $max_items = (int)$request->get('max_items')?:10; + $page = (int)$request->get('page')?:1; + $offset = ($max_items * ($page - 1)) + 1; $caption = $story->get_caption(); diff --git a/lib/Alchemy/Phrasea/ControllerProvider/Api/V1.php b/lib/Alchemy/Phrasea/ControllerProvider/Api/V1.php index 597e34aec7..d64689eca2 100644 --- a/lib/Alchemy/Phrasea/ControllerProvider/Api/V1.php +++ b/lib/Alchemy/Phrasea/ControllerProvider/Api/V1.php @@ -25,8 +25,6 @@ class V1 extends Api implements ControllerProviderInterface, ServiceProviderInte { const VERSION = '2.0.0'; - const HEADER_ACCEPT_STORY_PAGINATE = 'application/vnd.phraseanet.story-paginate'; - public static $extendedContentTypes = [ 'json' => ['application/vnd.phraseanet.record-extended+json'], 'yaml' => ['application/vnd.phraseanet.record-extended+yaml'],