Skip to content

Commit 0507b00

Browse files
committed
feat: ✨ Branch feature support added
1 parent 974ea41 commit 0507b00

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

src/Contentstack.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ abstract class Contentstack
4646
public static function Stack($api_*** = '',
4747
$access_token = '',
4848
$environment = '',
49-
$config = array('region'=> '')
49+
$config = array('region'=> '', 'branch'=> '')
5050
) {
5151
return new Stack($api_***, $access_token, $environment, $config);
5252
}

src/Stack/Stack.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(
5555
$api_*** = '',
5656
$delivery_token = '',
5757
$environment = '',
58-
$config = array('region'=> '')
58+
$config = array('region'=> '', 'branch'=> '')
5959
) {
6060

6161
if ($config && $config !== "undefined" && $config['region'] !== "undefined" && $config['region'] =="eu" ) {
@@ -65,7 +65,8 @@ public function __construct(
6565
'stack', array('api_***' => $api_***,
6666
'access_token' => $delivery_token,
6767
'environment' => $environment,
68-
'region' => $config['region'] ?? '')
68+
'region' => $config['region'] ?? '',
69+
'branch' => $config['branch'] ?? '')
6970
);
7071
$this->environment = $this->header['environment'];
7172
unset($this->header['environment']);
@@ -220,7 +221,7 @@ public function getPort()
220221
/**
221222
* This function sets API Key.
222223
*
223-
* @param string $api_*** - Name of Environment
224+
* @param string $api_*** - API Key
224225
*
225226
* @return Stack
226227
* */
@@ -233,7 +234,7 @@ public function setAPIKEY($api_*** = '')
233234
/**
234235
* This function sets Delivery Token.
235236
*
236-
* @param string $delivery_token - Name of Environment
237+
* @param string $delivery_token - Delivery Token
237238
*
238239
* @return Stack
239240
* */
@@ -286,6 +287,31 @@ public function getEnvironment()
286287
return $this->environment;
287288
}
288289

290+
291+
/**
292+
* This function sets Branch.
293+
*
294+
* @param string $branch - Name of branch
295+
*
296+
* @return Stack
297+
* */
298+
public function setBranch($branch = '')
299+
{
300+
Utility::validateInput('branch', $branch);
301+
$this->header['branch'] = $branch;
302+
return $this;
303+
}
304+
305+
/**
306+
* This function returns Branch.
307+
*
308+
* @return string
309+
* */
310+
public function Branch()
311+
{
312+
return $this->header['branch'];
313+
}
314+
289315
/**
290316
* This call returns comprehensive information of all
291317
* the content types available in a particular stack in your account.

src/Support/Utility.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,11 @@ public static function contentstackRequest($queryObject = '', $type = '')
375375
$request_headers[] = 'x-user-agent: contentstack-php/1.6.1';
376376
$request_headers[] = 'api_***: '.$Headers["api_***"];
377377
$request_headers[] = 'access_token: '.$Headers["access_token"];
378+
379+
if ($Headers["branch"] !== '' && $Headers["branch"] !== "undefined") {
380+
$request_headers[] = 'branch: '.$Headers["branch"];
381+
}
382+
378383
curl_setopt($http, CURLOPT_HTTPHEADER, $request_headers);
379384

380385
curl_setopt($http, CURLOPT_HEADER, false);

0 commit comments

Comments
 (0)