From 8c5457d496a4541060c5b8e5ae040db328ee4fdc Mon Sep 17 00:00:00 2001 From: aina-esokia Date: Mon, 9 Jul 2018 14:51:52 +0400 Subject: [PATCH] fix api version --- lib/Alchemy/Phrasea/Controller/Api/Result.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Controller/Api/Result.php b/lib/Alchemy/Phrasea/Controller/Api/Result.php index 148b679f9f..15624e1f6e 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/Result.php +++ b/lib/Alchemy/Phrasea/Controller/Api/Result.php @@ -11,6 +11,7 @@ namespace Alchemy\Phrasea\Controller\Api; +use Alchemy\Phrasea\ControllerProvider\Api\V1; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -267,7 +268,13 @@ class Result public function getVersion() { if (null === $this->version) { - $this->version = $this->request->attributes->get('api_version') ?: self::$defaultVersion; + if($this->request->attributes->get('api_version')){ + $this->version = $this->request->attributes->get('api_version'); + }elseif(mb_strpos($this->request->getPathInfo(), '/api/v1') !== FALSE){ + $this->version = V1::VERSION; + }else{ + $this->version = self::$defaultVersion; + } } return $this->version;