@@ -34,6 +34,11 @@ final class ParseClient
34
34
*/
35
35
private static $ masterKey ;
36
36
37
+ /**
38
+ * @var - Boolean for Enable/Disable curl exceptions.
39
+ */
40
+ private static $ enableCurlExceptions ;
41
+
37
42
/**
38
43
* @var ParseStorageInterface Object for managing persistence
39
44
*/
@@ -48,20 +53,22 @@ final class ParseClient
48
53
/**
49
54
* Parse\Client::initialize, must be called before using Parse features.
50
55
*
51
- * @param string $app_id Parse Application ID
52
- * @param string $rest_key Parse REST API Key
53
- * @param string $master_key Parse Master Key
56
+ * @param string $app_id Parse Application ID
57
+ * @param string $rest_key Parse REST API Key
58
+ * @param string $master_key Parse Master Key
59
+ * @param string $enableCurlExceptions Enable or disable Parse curl exceptions
54
60
*
55
61
* @return null
56
62
*/
57
- public static function initialize ($ app_id , $ rest_key , $ master_key )
63
+ public static function initialize ($ app_id , $ rest_key , $ master_key, $ enableCurlExceptions = true )
58
64
{
59
65
ParseUser::registerSubclass ();
60
66
ParseRole::registerSubclass ();
61
67
ParseInstallation::registerSubclass ();
62
68
self ::$ applicationId = $ app_id ;
63
69
self ::$ restKey = $ rest_key ;
64
70
self ::$ masterKey = $ master_key ;
71
+ self ::$ enableCurlExceptions = $ enableCurlExceptions ;
65
72
if (!static ::$ storage ) {
66
73
if (session_status () === PHP_SESSION_ACTIVE ) {
67
74
self ::setStorage (new ParseSessionStorage ());
@@ -247,7 +254,11 @@ public static function _request($method, $relativeUrl, $sessionToken = null,
247
254
$ status = curl_getinfo ($ rest , CURLINFO_HTTP_CODE );
248
255
$ contentType = curl_getinfo ($ rest , CURLINFO_CONTENT_TYPE );
249
256
if (curl_errno ($ rest )) {
250
- throw new ParseException (curl_error ($ rest ), curl_errno ($ rest ));
257
+ if (self ::$ enableCurlExceptions ) {
258
+ throw new ParseException (curl_error ($ rest ), curl_errno ($ rest ));
259
+ } else {
260
+ return false ;
261
+ }
251
262
}
252
263
curl_close ($ rest );
253
264
if (strpos ($ contentType , 'text/html ' ) !== false ) {
@@ -280,7 +291,7 @@ public static function setStorage(ParseStorageInterface $storageObject)
280
291
/**
281
292
* ParseClient::getStorage, will return the storage object used for
282
293
* persistence.
283
-
294
+ *
284
295
* @return ParseStorageInterface
285
296
*/
286
297
public static function getStorage ()
0 commit comments