Example #1
0
 /**
  * @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);
 }