/** * @param \CultuurNet\Auth\Session $session * @param string $path */ public static function write(Session $session, $path) { $hash = array(); $consumerCredentials = $session->getConsumerCredentials(); if (NULL != $consumerCredentials) { $hash['consumer'] = array('key' => $consumerCredentials->getKey(), 'secret' => $consumerCredentials->getSecret()); } $user = $session->getUser(); if (NULL !== $user) { $hash['user'] = array('id' => $user->getId(), 'token' => $user->getTokenCredentials()->getToken(), 'secret' => $user->getTokenCredentials()->getSecret()); } $baseUrls = $session->getBaseUrls(); if (!empty($baseUrls)) { $hash['baseUrls'] = $baseUrls; } $json = json_encode($hash); // @todo Throw exception if unable to save. file_put_contents($path, $json); }
/** * */ protected function resolveBaseUrl($api, InputInterface $in = NULL, $default = 'http://acc.uitid.be/uitid/rest') { if (NULL === $this->session) { // @todo throw exception as session isn't initialized yet } if ($in->hasOption($api . '-base-url')) { $baseUrl = $in->getOption($api . '-base-url'); } else { if ($in->hasOption('base-url')) { $baseUrl = $in->getOption('base-url'); } } if (isset($baseUrl)) { $this->session->setBaseUrl($api, $baseUrl); } else { if ('' == $this->session->getBaseUrl($api)) { $baseUrl = isset($this->defaults['base-url'][$api]) ? $this->defaults['base-url'][$api] : $default; $this->session->setBaseUrl($api, $baseUrl); } else { $baseUrl = $this->session->getBaseUrl($api); } } return $baseUrl; }