Set OAuth2_Adapter default API version

This commit is contained in:
Benoît Burnichon
2016-02-16 13:48:35 +01:00
parent 41287802ca
commit 27eaf37a45
2 changed files with 4 additions and 4 deletions

View File

@@ -21,7 +21,7 @@ class APIServiceProvider implements ServiceProviderInterface
public function register(Application $app)
{
$app['oauth2-server'] = $app->share(function ($app) {
return new \API_OAuth2_Adapter($app);
return new \API_OAuth2_Adapter($app, ['api_version' => $app['api.default_version']]);
});
$app['token'] = $app->share(function (Application $app) {
/** @var \API_OAuth2_Adapter $oauth2 */

View File

@@ -473,16 +473,16 @@ class API_OAuth2_Adapter extends OAuth2
* @param User $user
*
* @return mixed
* @throws logicalException
* @throws LogicException
*/
public function updateAccount(User $user)
{
if ($this->client === null) {
throw new logicalException("Client property must be set before update an account");
throw new LogicException("Client property must be set before update an account");
}
if (null === $account = $this->app['repo.api-accounts']->findByUserAndApplication($user, $this->client)) {
$account = $this->app['manipulator.api-account']->create($this->client, $user);
$account = $this->app['manipulator.api-account']->create($this->client, $user, $this->getVariable('api_version', V2::VERSION));
}
return $account;