diff --git a/README.md b/README.md index 00ac1305..38266019 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ apiBaseUrl apiVersion access_type accounts_url +persistence_handler persistence_handler_class token_persistence_path db_port @@ -117,7 +118,9 @@ applicationLogFilePath - The SDK stores the log information in a file. The file path of the folder must be specified in the key and the SDK automatically creates the file. The default file name is the ZCRMClientLibrary.log. In case the path isn't specified, the log file will be created inside the project. -persistence_handler_class is the implementation of the ZohoOAuthPersistenceInterface. +persistence_handler_class is the implementation of the ZohoOAuthPersistenceInterface. This will instantiate a class based on the file location. eg \home\php\CustomPersistence.php + +persistence_handler - You can inject an instantiated persistence hander into the configuration during run time to pass yourcustom persistence handler to the XohoOAuth class. >If the Optional keys are not specified, their default values will be assigned automatically. >The 'apiBaseUrl' and 'accounts_url' are mandatory in case the user is not in the "com" domain. diff --git a/composer.json b/composer.json index a72fdf22..293b5d2a 100644 --- a/composer.json +++ b/composer.json @@ -21,4 +21,4 @@ "zcrmsdk\\" : "src/" } } -} \ No newline at end of file +} diff --git a/src/crm/exception/ZCRMException.php b/src/crm/exception/ZCRMException.php index 2f420db1..75c3f5e3 100644 --- a/src/crm/exception/ZCRMException.php +++ b/src/crm/exception/ZCRMException.php @@ -11,13 +11,7 @@ class ZCRMException extends \Exception // Unknown protected $code = 0; - - // User-defined exception code - protected $file; - - // Source filename of exception - protected $line; - + // Source line of exception private $trace; @@ -77,4 +71,4 @@ public function setExceptionDetails($exceptionDetails) { $this->exceptionDetails = $exceptionDetails; } -} \ No newline at end of file +} diff --git a/src/oauth/ZohoOAuth.php b/src/oauth/ZohoOAuth.php index 2d69dc99..c5085903 100644 --- a/src/oauth/ZohoOAuth.php +++ b/src/oauth/ZohoOAuth.php @@ -5,6 +5,7 @@ use zcrmsdk\oauth\exception\ZohoOAuthException; use zcrmsdk\oauth\persistence\ZohoOAuthPersistenceByFile; use zcrmsdk\oauth\persistence\ZohoOAuthPersistenceHandler; +use zcrmsdk\oauth\persistence\ZohoOAuthPersistenceInterface; use zcrmsdk\oauth\utility\ZohoOAuthConstants; use zcrmsdk\oauth\utility\ZohoOAuthParams; @@ -48,6 +49,7 @@ private static function setConfigValues($configuration) ZohoOAuthConstants::CLIENT_SECRET, ZohoOAuthConstants::REDIRECT_URL, ZohoOAuthConstants::ACCESS_TYPE, + ZohoOAuthConstants::PERSISTENCE_HANDLER, ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS, ZohoOAuthConstants::IAM_URL, ZohoOAuthConstants::TOKEN_PERSISTENCE_PATH, @@ -140,6 +142,9 @@ public static function getPersistenceHandlerInstance() if(ZohoOAuth::getConfigValue("token_persistence_path")!=""){ return new ZohoOAuthPersistenceByFile() ; } + else if(self::$configProperties[ZohoOAuthConstants::PERSISTENCE_HANDLER] instanceof ZohoOAuthPersistenceInterface){ + return self::$configProperties[ZohoOAuthConstants::PERSISTENCE_HANDLER]; + } else if(self::$configProperties[ZohoOAuthConstants::PERSISTENCE_HANDLER_CLASS] == "ZohoOAuthPersistenceHandler"){ return new ZohoOAuthPersistenceHandler(); } @@ -161,4 +166,4 @@ public static function getClientInstance() } return ZohoOAuthClient::getInstanceWithOutParam(); } -} \ No newline at end of file +} diff --git a/src/oauth/utility/ZohoOAuthConstants.php b/src/oauth/utility/ZohoOAuthConstants.php index 0523b737..80d817e9 100644 --- a/src/oauth/utility/ZohoOAuthConstants.php +++ b/src/oauth/utility/ZohoOAuthConstants.php @@ -52,6 +52,8 @@ class ZohoOAuthConstants const EXPIRIY_TIME = "expiry_time"; + const PERSISTENCE_HANDLER = "persistence_handler"; + const PERSISTENCE_HANDLER_CLASS = "persistence_handler_class"; const PERSISTENCE_HANDLER_CLASS_NAME = "persistence_handler_class_name"; @@ -86,4 +88,4 @@ class ZohoOAuthConstants const RESPONSECODE_OK = 200; -} \ No newline at end of file +}