Skip to content

Commit

Permalink
Merge pull request #31 from 42mate/master
Browse files Browse the repository at this point in the history
Remove .config.json dependency
  • Loading branch information
DivineOmega authored Feb 10, 2017
2 parents a2511af + 9abe0d1 commit 84c0b75
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions helpers/GoogleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,33 @@

abstract class GoogleHelper
{
private static $_config;

public static function initConfig(
$clientID,
$clientSecret,
$redirectUri,
$developerKey,
$refreshToken
) {
self::$_config = new \stdClass();
self::$_config->clientID = $clientID;
self::$_config->clientSecret = $clientSecret;
self::$_config->redirectUri = $redirectUri;
self::$_config->developerKey = $developerKey;
self::$_config->refreshToken = $refreshToken;
}

private static function loadConfig()
{
$configPath = __DIR__.'/../../../../.config.json';
if(!file_exists($configPath)) throw new \Exception('Not found config.json');
$contents = file_get_contents($configPath);
$config = json_decode($contents);
if (NULL === self::$_config) {
$configPath = __DIR__.'/../../../../.config.json';
if(!file_exists($configPath)) throw new \Exception('Not found config.json');
$contents = file_get_contents($configPath);
self::$_config = json_decode($contents);
}

return $config;
return self::$_config;
}

public static function getClient()
Expand Down

0 comments on commit 84c0b75

Please sign in to comment.