1010class ZohoOAuthPersistenceByFile implements ZohoOAuthPersistenceInterface
1111{
1212
13- public function setIncludePath ()
13+ public function getTokenPersistencePath ()
1414 {
1515 $ path = ZohoOAuth::getConfigValue ('token_persistence_path ' );
1616 $ path = trim ($ path );
17- set_include_path ( $ path) ;
17+ return $ path ;
1818 }
1919
2020 public function saveOAuthData ($ zohoOAuthTokens )
2121 {
2222 try {
2323 self ::deleteOAuthTokens ($ zohoOAuthTokens ->getUserEmailId ());
24- self ::setIncludePath ();
25- $ content = file_get_contents ("zcrm_oauthtokens.txt " , FILE_USE_INCLUDE_PATH );
24+ $ content = file_get_contents (self ::getTokenPersistencePath ()."/zcrm_oauthtokens.txt " );
2625 if ($ content == "" ) {
2726 $ arr = array ();
2827 } else {
2928 $ arr = unserialize ($ content );
3029 }
3130 array_push ($ arr , $ zohoOAuthTokens );
3231 $ serialized = serialize ($ arr );
33- file_put_contents (" zcrm_oauthtokens.txt " , $ serialized, FILE_USE_INCLUDE_PATH );
32+ file_put_contents (self :: getTokenPersistencePath (). " / zcrm_oauthtokens.txt " ,$ serialized );
3433 } catch (Exception $ ex ) {
3534 Logger::severe ("Exception occured while Saving OAuthTokens to file(file::ZohoOAuthPersistenceByFile)( {$ ex ->getMessage ()}) \n{$ ex }" );
3635 throw $ ex ;
@@ -40,8 +39,7 @@ public function saveOAuthData($zohoOAuthTokens)
4039 public function getOAuthTokens ($ userEmailId )
4140 {
4241 try {
43- self ::setIncludePath ();
44- $ serialized = file_get_contents ("zcrm_oauthtokens.txt " , FILE_USE_INCLUDE_PATH );
42+ $ serialized = file_get_contents (self ::getTokenPersistencePath ()."/zcrm_oauthtokens.txt " );
4543 if (! isset ($ serialized ) || $ serialized == "" ) {
4644 throw new ZohoOAuthException ("No Tokens exist for the given user-identifier,Please generate and try again. " );
4745 }
@@ -71,8 +69,7 @@ public function getOAuthTokens($userEmailId)
7169 public function deleteOAuthTokens ($ userEmailId )
7270 {
7371 try {
74- self ::setIncludePath ();
75- $ serialized = file_get_contents ("zcrm_oauthtokens.txt " , FILE_USE_INCLUDE_PATH );
72+ $ serialized = file_get_contents (self ::getTokenPersistencePath ()."/zcrm_oauthtokens.txt " );
7673 if (! isset ($ serialized ) || $ serialized == "" ) {
7774 return ;
7875 }
@@ -90,7 +87,7 @@ public function deleteOAuthTokens($userEmailId)
9087 $ arr = array_values (array_filter ($ arr ));
9188 }
9289 $ serialized = serialize ($ arr );
93- file_put_contents (" zcrm_oauthtokens.txt " , $ serialized, FILE_USE_INCLUDE_PATH );
90+ file_put_contents (self :: getTokenPersistencePath (). " / zcrm_oauthtokens.txt " ,$ serialized );
9491 } catch (Exception $ ex ) {
9592 Logger::severe ("Exception occured while Saving OAuthTokens to file(file::ZohoOAuthPersistenceByFile)( {$ ex ->getMessage ()}) \n{$ ex }" );
9693 throw $ ex ;
0 commit comments