public function testGettersAndSetters() { $this->assertTrue(is_int($this->object->get_id())); $this->assertInstanceOf('Alchemy\\Phrasea\\Model\\Entities\\User', $this->object->get_user()); $this->assertEquals(self::$DI['user']->getId(), $this->object->get_user()->getId()); $this->assertEquals('1.0', $this->object->get_api_version()); $this->assertTrue(is_bool($this->object->is_revoked())); $this->object->set_revoked(true); $this->assertTrue($this->object->is_revoked()); $this->object->set_revoked(false); $this->assertFalse($this->object->is_revoked()); $this->assertInstanceOf('DateTime', $this->object->get_created_on()); $this->assertInstanceOf('API_OAuth2_Token', $this->object->get_token()); $this->assertInstanceOf('API_OAuth2_Application', $this->object->get_application()); $this->assertEquals(self::$DI['oauth2-app-user'], $this->object->get_application()); }
public static function create(Application $app, API_OAuth2_Account $account, $route, $status_code, $format, $ressource, $general = null, $aspect = null, $action = null) { $sql = ' INSERT INTO api_logs ( api_log_id, api_account_id, api_log_route, api_log_date, api_log_status_code, api_log_format, api_log_ressource, api_log_general, api_log_aspect, api_log_action ) VALUES ( null, :account_id, :route, NOW(), :status_code, :format, :ressource, :general, :aspect, :action )'; $params = [':account_id' => $account->get_id(), ':route' => $route, ':status_code' => $status_code, ':format' => $format, ':ressource' => $ressource, ':general' => $general, ':aspect' => $aspect, ':action' => $action]; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); $log_id = $app['phraseanet.appbox']->get_connection()->lastInsertId(); return new self($app, $log_id); }
/** * * @param appbox $appbox * @param API_OAuth2_Account $account * @param string $scope * @return API_OAuth2_Token */ public static function create(appbox $appbox, API_OAuth2_Account $account, $scope = null) { $sql = 'INSERT INTO api_oauth_tokens (oauth_token, session_id, api_account_id, expires, scope) VALUES (:token, null, :account_id, :expire, :scope)'; $expires = new \DateTime('+1 hour'); $params = [':token' => self::generate_token(), ':account_id' => $account->get_id(), ':expire' => $expires->format(DATE_ISO8601), ':scope' => $scope]; $stmt = $appbox->get_connection()->prepare($sql); $stmt->execute($params); $stmt->closeCursor(); return new API_OAuth2_Token($appbox, $account); }
/** * * @param Application $app * @param API_OAuth2_Account $account * @param int $expires * @param type $refresh_token * @param type $scope * @return API_OAuth2_RefreshToken */ public static function create(Application $app, API_OAuth2_Account $account, $expires, $refresh_token, $scope) { $sql = 'INSERT INTO api_oauth_refresh_tokens (refresh_token, api_account_id, expires, scope) VALUES (:refresh_token, :account_id, :expires, :scope)'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $params = [":refresh_token" => $refresh_token, ":account_id" => $account->get_id(), ":expires" => $expires, ":scope" => $scope]; $stmt->execute($params); $stmt->closeCursor(); return new self($app, $refresh_token); }
/** * * @param Application $app * @param API_OAuth2_Account $account * @param type $code * @param int $expires * @return API_OAuth2_AuthCode */ public static function create(Application $app, API_OAuth2_Account $account, $code, $expires) { $sql = 'INSERT INTO api_oauth_codes (code, api_account_id, expires) VALUES (:code, :account_id, FROM_UNIXTIME(:expires))'; $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $params = [":code" => $code, ":account_id" => $account->get_id(), ":expires" => $expires]; $stmt->execute($params); $stmt->closeCursor(); return new self($app, $code); }