From e9311eea677fd54aa62000dc10ec51244429ecd5 Mon Sep 17 00:00:00 2001 From: Marcos Ibanez Date: Sun, 5 Feb 2017 15:05:16 -0800 Subject: [PATCH 1/3] Testing composer override --- helpers/GoogleHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/helpers/GoogleHelper.php b/helpers/GoogleHelper.php index 226af08..4698589 100644 --- a/helpers/GoogleHelper.php +++ b/helpers/GoogleHelper.php @@ -6,6 +6,7 @@ abstract class GoogleHelper { private static function loadConfig() { + die(var_dump('test')); $configPath = __DIR__.'/../../../../.config.json'; if(!file_exists($configPath)) throw new \Exception('Not found config.json'); $contents = file_get_contents($configPath); From 587a229d0b2abb53209b96145c3e7ac74f258221 Mon Sep 17 00:00:00 2001 From: Marcos Ibanez Date: Sun, 5 Feb 2017 16:16:11 -0800 Subject: [PATCH 2/3] Added method to allow initialization from sources other than file --- helpers/GoogleHelper.php | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/helpers/GoogleHelper.php b/helpers/GoogleHelper.php index 4698589..6456783 100644 --- a/helpers/GoogleHelper.php +++ b/helpers/GoogleHelper.php @@ -4,15 +4,34 @@ abstract class GoogleHelper { + private static $_config; + + public static function initConfig( + $clientID, + $clientSecret, + $redirectUri, + $developerKey, + $refreshToken + ) { + self::$_config = [ + 'clientID' => $clientID, + 'clientSecret' => $clientSecret, + 'redirectUri' => $redirectUri, + 'developerKey' => $developerKey, + 'refreshToken' => $refreshToken, + ]; + } + private static function loadConfig() { - die(var_dump('test')); - $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() From 9abe0d1feba921c71fc646587cee7c7d63ac20e0 Mon Sep 17 00:00:00 2001 From: Marcos Ibanez Date: Sun, 5 Feb 2017 17:13:06 -0800 Subject: [PATCH 3/3] Converted configuration to object --- helpers/GoogleHelper.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/helpers/GoogleHelper.php b/helpers/GoogleHelper.php index 6456783..123b12a 100644 --- a/helpers/GoogleHelper.php +++ b/helpers/GoogleHelper.php @@ -13,13 +13,12 @@ public static function initConfig( $developerKey, $refreshToken ) { - self::$_config = [ - 'clientID' => $clientID, - 'clientSecret' => $clientSecret, - 'redirectUri' => $redirectUri, - 'developerKey' => $developerKey, - 'refreshToken' => $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()