public __construct ( array $config ) | ||
$config | array | Required |
public function __construct(array $config)
{
// check for system requirements
$this->checkRequirements();
// now we are ready to go on...
if (isset($config['domain'])) {
$this->domain = $config['domain'];
} else {
throw new CoreException('Invalid domain');
}
if (isset($config['client_id'])) {
$this->client_id = $config['client_id'];
} else {
throw new CoreException('Invalid client_id');
}
if (isset($config['client_secret'])) {
$this->client_secret = $config['client_secret'];
} else {
throw new CoreException('Invalid client_secret');
}
if (isset($config['redirect_uri'])) {
$this->redirect_uri = $config['redirect_uri'];
} else {
throw new CoreException('Invalid redirect_uri');
}
if (isset($config['debug'])) {
$this->debug_mode = $config['debug'];
} else {
$this->debug_mode = false;
}
// User info is persisted unless said otherwise
if (isset($config['persist_user']) && $config['persist_user'] === false) {
$this->dontPersist('user');
}
// Access token is not persisted unless said otherwise
if (!isset($config['persist_access_token']) || isset($config['persist_access_token']) && $config['persist_access_token'] === false) {
$this->dontPersist('access_token');
}
// Refresh token is not persisted unless said otherwise
if (!isset($config['persist_refresh_token']) || isset($config['persist_refresh_token']) && $config['persist_refresh_token'] === false) {
$this->dontPersist('refresh_token');
}
// Id token is not per persisted unless said otherwise
if (!isset($config['persist_id_token']) || isset($config['persist_id_token']) && $config['persist_id_token'] === false) {
$this->dontPersist('id_token');
}
if (isset($config['store'])) {
if ($config['store'] === false) {
$this->store = new EmptyStore();
} else {
$this->store = $config['store'];
}
} else {
$this->store = new SessionStore();
}
$this->oauth_client = new Client($this->client_id, $this->client_secret);
$this->user = $this->store->get("user");
$this->access_token = $this->store->get("access_token");
$this->id_token = $this->store->get("id_token");
$this->refresh_token = $this->store->get("refresh_token");
if (!$this->access_token) {
$this->oauth_client->setAccessToken($this->access_token);
}
}