fix api version

This commit is contained in:
aina-esokia
2018-07-09 14:51:52 +04:00
parent 40fbdd4fd9
commit 8c5457d496

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\Controller\Api; namespace Alchemy\Phrasea\Controller\Api;
use Alchemy\Phrasea\ControllerProvider\Api\V1;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@@ -267,7 +268,13 @@ class Result
public function getVersion() public function getVersion()
{ {
if (null === $this->version) { 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; return $this->version;