public static function push($config = null, $clientId, $accessToken, $tokenCreateTime, $tokenExpiresIn)
{
// Return if not enabled
if (!self::isEnabled($config)) {
return;
}
$cachePath = self::cachePath($config);
if (!is_dir(dirname($cachePath))) {
if (mkdir(dirname($cachePath), 0755, true) == false) {
throw new \Exception("Failed to create directory at {$cachePath}");
}
}
// Reads all the existing persisted data
$tokens = self::pull();
$tokens = $tokens ? $tokens : array();
if (is_array($tokens)) {
$tokens[$clientId] = array('clientId' => $clientId, 'accessTokenEncrypted' => $accessToken, 'tokenCreateTime' => $tokenCreateTime, 'tokenExpiresIn' => $tokenExpiresIn);
}
if (!file_put_contents($cachePath, json_encode($tokens))) {
throw new \Exception("Failed to write cache");
}
}