Skip to content

Commit 1eb1c3c

Browse files
authored
refactor: Remove ParseApp and tests (#501)
1 parent 1cf234d commit 1eb1c3c

File tree

9 files changed

+19
-370
lines changed

9 files changed

+19
-370
lines changed

src/Parse/ParseApp.php

Lines changed: 0 additions & 142 deletions
This file was deleted.

src/Parse/ParseClient.php

Lines changed: 19 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@ final class ParseClient
6161
*/
6262
private static $enableCurlExceptions;
6363

64-
/**
65-
* The account key.
66-
*
67-
* @var string
68-
*/
69-
private static $accountKey;
70-
7164
/**
7265
* The object for managing persistence.
7366
*
@@ -132,8 +125,7 @@ public static function initialize(
132125
$app_id,
133126
$rest_key,
134127
$master_key,
135-
$enableCurlExceptions = true,
136-
$account_key = null
128+
$enableCurlExceptions = true
137129
) {
138130
if (!ParseObject::hasRegisteredSubclass('_User')) {
139131
ParseUser::registerSubclass();
@@ -160,7 +152,6 @@ public static function initialize(
160152
self::$restKey = $rest_key;
161153
self::$masterKey = $master_key;
162154
self::$enableCurlExceptions = $enableCurlExceptions;
163-
self::$accountKey = $account_key;
164155
if (!static::$storage) {
165156
if (session_status() === PHP_SESSION_ACTIVE) {
166157
self::setStorage(new ParseSessionStorage());
@@ -484,7 +475,6 @@ private static function createRequestUrl($relativeUrl)
484475
* @param null $sessionToken Session Token.
485476
* @param null $data Data to provide with the request.
486477
* @param bool $useMasterKey Whether to use the Master Key.
487-
* @param bool $appRequest App request to create or modify a application
488478
* @param string $contentType The content type for this request, default is application/json
489479
* @param bool $returnHeaders Allow to return response headers
490480
*
@@ -498,7 +488,6 @@ public static function _request(
498488
$sessionToken = null,
499489
$data = null,
500490
$useMasterKey = false,
501-
$appRequest = false,
502491
$contentType = 'application/json',
503492
$returnHeaders = false
504493
) {
@@ -511,37 +500,29 @@ public static function _request(
511500

512501
// verify the server url and mount path have been set
513502
self::assertServerInitialized();
503+
self::assertParseInitialized();
514504

515-
if ($appRequest) {
516-
// ** 'app' requests are not available in open source parse-server
517-
self::assertAppInitialized();
518-
519-
$httpClient->addRequestHeader('X-Parse-Account-Key', self::$accountKey);
520-
} else {
521-
self::assertParseInitialized();
522-
523-
// add appId & client version
524-
$httpClient->addRequestHeader('X-Parse-Application-Id', self::$applicationId);
525-
$httpClient->addRequestHeader('X-Parse-Client-Version', 'php' . self::VERSION_STRING);
505+
// add appId & client version
506+
$httpClient->addRequestHeader('X-Parse-Application-Id', self::$applicationId);
507+
$httpClient->addRequestHeader('X-Parse-Client-Version', 'php' . self::VERSION_STRING);
526508

527509

528-
if ($sessionToken) {
529-
// add our current session token
530-
$httpClient->addRequestHeader('X-Parse-Session-Token', $sessionToken);
531-
}
510+
if ($sessionToken) {
511+
// add our current session token
512+
$httpClient->addRequestHeader('X-Parse-Session-Token', $sessionToken);
513+
}
532514

533-
if ($useMasterKey) {
534-
// pass master key
535-
$httpClient->addRequestHeader('X-Parse-Master-Key', self::$masterKey);
536-
} elseif (isset(self::$restKey)) {
537-
// pass REST key
538-
$httpClient->addRequestHeader('X-Parse-REST-API-Key', self::$restKey);
539-
}
515+
if ($useMasterKey) {
516+
// pass master key
517+
$httpClient->addRequestHeader('X-Parse-Master-Key', self::$masterKey);
518+
} elseif (isset(self::$restKey)) {
519+
// pass REST key
520+
$httpClient->addRequestHeader('X-Parse-REST-API-Key', self::$restKey);
521+
}
540522

541-
if (self::$forceRevocableSession) {
542-
// indicate we are using revocable sessions
543-
$httpClient->addRequestHeader('X-Parse-Revocable-Session', '1');
544-
}
523+
if (self::$forceRevocableSession) {
524+
// indicate we are using revocable sessions
525+
$httpClient->addRequestHeader('X-Parse-Revocable-Session', '1');
545526
}
546527

547528
/*
@@ -713,22 +694,6 @@ private static function assertParseInitialized()
713694
}
714695
}
715696

716-
/**
717-
* Asserts that the sdk has been initialized with a valid account key
718-
*
719-
* @throws Exception
720-
*/
721-
private static function assertAppInitialized()
722-
{
723-
if (self::$accountKey === null || empty(self::$accountKey)) {
724-
throw new Exception(
725-
'You must call ParseClient::initialize(..., $accountKey) before making any app requests. '.
726-
'Your account key must not be null or empty.',
727-
109
728-
);
729-
}
730-
}
731-
732697
/**
733698
* Get remote Parse API url.
734699
*

src/Parse/ParseCloud.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public static function startJob($jobName, $data = [])
7272
null,
7373
json_encode(ParseClient::_encode($data, false)),
7474
true,
75-
false,
7675
'application/json',
7776
true
7877
);

src/Parse/ParseFile.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ private function upload($useMasterKey = false)
229229
null,
230230
$this->getData(),
231231
$useMasterKey,
232-
false,
233232
$mimeType
234233
);
235234
}

src/Parse/ParsePush.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public static function send($data, $useMasterKey = false)
7878
null,
7979
json_encode(ParseClient::_encode($data, true)),
8080
$useMasterKey,
81-
false,
8281
'application/json',
8382
true
8483
);

tests/Parse/Helper.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ class Helper
2828
*/
2929
public static $masterKey = 'master-key-here';
3030

31-
/**
32-
* Account Key (for parse.com)
33-
* @var string
34-
*/
35-
public static $accountKey = 'account-key';
36-
37-
3831
public static function setUp()
3932
{
4033
ini_set('error_reporting', E_ALL);
@@ -46,7 +39,6 @@ public static function setUp()
4639
self::$restKey,
4740
self::$masterKey,
4841
true,
49-
self::$accountKey
5042
);
5143
self::setServerURL();
5244
self::setHttpClient();
@@ -106,7 +98,6 @@ public static function setUpWithoutCURLExceptions()
10698
self::$restKey,
10799
self::$masterKey,
108100
false,
109-
self::$accountKey
110101
);
111102
}
112103

0 commit comments

Comments
 (0)