public function __construct(\OAuth2Yii\Component\ServerComponent $server, $redis = []) { parent::__construct($server); //Merges default configuration with provided (if any) $params = array_merge(['host' => '127.0.0.1', 'port' => 6379, 'database' => 1], $redis); $this->redis = new \Predis\Client($params); $this->config = array('client_key' => 'oauth_clients:', 'access_token_key' => 'oauth_access_tokens:', 'refresh_token_key' => 'oauth_refresh_tokens:', 'code_key' => 'oauth_authorization_codes:', 'user_key' => 'oauth_users:', 'jwt_key' => 'oauth_jwt:', 'scope_key' => 'oauth_scopes:'); }
/** * @param \OAuth2Yii\Component\ServerComponent $server the server component * @param string $className name of the custom storage class * * @throws \CException if the specified class doesn't implement the correct interface */ public function __construct(\OAuth2Yii\Component\ServerComponent $server, $className) { parent::__construct($server); $this->_storage = new $className(); if (!is_a($this->_storage, $this->getInterface())) { throw new CException("Class must implement {$this->getInterface()}"); } }
/** * @param \OAuth2Yii\Component\ServerComponent $server the server component * @param string $db id of the CDbConnection component * * @throws \CException if the component cannot be found */ public function __construct(\OAuth2Yii\Component\ServerComponent $server, $db) { parent::__construct($server); if (!Yii::app()->hasComponent($db)) { throw new CException("Unknown component '{$db}'"); } $this->_db = Yii::app()->getComponent($db); if (!in_array($this->getTableName(), $this->_db->getSchema()->getTableNames())) { $this->createTable(); } }