fix api/v3 api_version

This commit is contained in:
aynsix
2019-12-06 14:24:03 +04:00
parent 2fd5b6cba2
commit f475a5c925
3 changed files with 13 additions and 7 deletions

View File

@@ -12,6 +12,7 @@
namespace Alchemy\Phrasea\Controller\Api; namespace Alchemy\Phrasea\Controller\Api;
use Alchemy\Phrasea\ControllerProvider\Api\V1; use Alchemy\Phrasea\ControllerProvider\Api\V1;
use Alchemy\Phrasea\ControllerProvider\Api\V3;
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;
@@ -272,6 +273,8 @@ class Result
$this->version = $this->request->attributes->get('api_version'); $this->version = $this->request->attributes->get('api_version');
} elseif (mb_strpos($this->request->getPathInfo(), '/api/v1') !== FALSE) { } elseif (mb_strpos($this->request->getPathInfo(), '/api/v1') !== FALSE) {
$this->version = V1::VERSION; $this->version = V1::VERSION;
} elseif (mb_strpos($this->request->getPathInfo(), '/api/v3') !== FALSE) {
$this->version = V3::VERSION;
} else { } else {
$this->version = self::$defaultVersion; $this->version = self::$defaultVersion;
} }

View File

@@ -12,7 +12,7 @@ use Silex\ServiceProviderInterface;
class V3 extends Api implements ControllerProviderInterface, ServiceProviderInterface class V3 extends Api implements ControllerProviderInterface, ServiceProviderInterface
{ {
const VERSION = '2.0.0'; const VERSION = '3.0.0';
public function register(Application $app) public function register(Application $app)
{ {

View File

@@ -15,6 +15,7 @@ use Alchemy\Phrasea\Authentication\Context;
use Alchemy\Phrasea\Controller\Api\Result; use Alchemy\Phrasea\Controller\Api\Result;
use Alchemy\Phrasea\ControllerProvider\Api\V1; use Alchemy\Phrasea\ControllerProvider\Api\V1;
use Alchemy\Phrasea\ControllerProvider\Api\V2; use Alchemy\Phrasea\ControllerProvider\Api\V2;
use Alchemy\Phrasea\ControllerProvider\Api\V3;
use Alchemy\Phrasea\Core\Configuration\PropertyAccess; use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
use Alchemy\Phrasea\Core\Event\ApiOAuth2EndEvent; use Alchemy\Phrasea\Core\Event\ApiOAuth2EndEvent;
use Alchemy\Phrasea\Core\Event\ApiOAuth2StartEvent; use Alchemy\Phrasea\Core\Event\ApiOAuth2StartEvent;
@@ -80,6 +81,8 @@ class OAuthListener
$request->attributes->set('api_version', V1::VERSION); $request->attributes->set('api_version', V1::VERSION);
} elseif(mb_strpos($CalledController, 'controller.api.v2') !== FALSE) { } elseif(mb_strpos($CalledController, 'controller.api.v2') !== FALSE) {
$request->attributes->set('api_version', V2::VERSION); $request->attributes->set('api_version', V2::VERSION);
} elseif(mb_strpos($CalledController, 'controller.api.v3') !== FALSE) {
$request->attributes->set('api_version', V3::VERSION);
} else { } else {
$request->attributes->set('api_version', $oAuth2Account->getApiVersion()); $request->attributes->set('api_version', $oAuth2Account->getApiVersion());
} }