Skip to content

Commit 7f7d52b

Browse files
Merge pull request #11 from contentstack/region
Region Support
2 parents 6436720 + aa01ce9 commit 7f7d52b

File tree

15 files changed

+30
-6
lines changed

15 files changed

+30
-6
lines changed

.gitignore

100644100755
File mode changed.

LICENSE.txt

100644100755
File mode changed.

config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
return new Sami\Sami('/Users/uttamukkoji/Documents/php/contentstack-php/src');
4+

examples/index.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<html>
22
<head>
3-
<title>Built.io Contentstack PHP SDK</title>
3+
<title>Contentstack PHP SDK</title>
44
</head>
55
<body>
66
<h1>Welcome to Contentstack PHP SDK</h1>
@@ -10,7 +10,8 @@
1010
ini_set('display_errors', 'On');
1111
use Contentstack\Contentstack;
1212
include_once "../src/index.php";
13-
$stack = Contentstack::Stack('', '', '');
13+
include_once "../src/contentstackregion.php";
14+
$stack = Contentstack::Stack('', '', '', '');
1415
try {
1516
// \Contentstack\Utility\debug($stack);
1617
// $result = $stack->getContentTypes('{"include_snippet_schema": "false"}');

src/config/index.php

100644100755
File mode changed.

src/contentstackregion.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/*
3+
* Dependency loading
4+
* */
5+
6+
class ContentstackRegion {
7+
const EU= "eu";
8+
const US= "us";
9+
}

src/lib/models/assets.php

100644100755
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,5 @@ public function fetch() {
6363
$this->operation = __FUNCTION__;
6464
return \Contentstack\Utility\contentstackRequest($this, 'asset');
6565
}
66-
67-
6866
}
6967

src/lib/models/csexception.php

100644100755
File mode changed.

src/lib/models/stack.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ class Stack {
2727
/*
2828
* Constructor of the Stack
2929
* */
30-
public function __construct($api_*** = '', $access_token = '', $environment = '') {
31-
$this->header = Utility\validateInput('stack', array('api_***' => $api_***, 'access_token' => $access_token, 'environment' => $environment));
30+
public function __construct($api_*** = '', $access_token = '', $environment = '', $region = '') {
31+
32+
if($region && $region =="eu" && $region !== "undefined") {
33+
$this->host = $region.'-'.HOST;
34+
}
35+
$this->header = Utility\validateInput('stack', array('api_***' => $api_***, 'access_token' => $access_token, 'environment' => $environment, 'region' => $region));
3236
$this->environment = $this->header['environment'];
3337
unset($this->header['environment']);
3438
return $this;

src/lib/utility.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ function validateInput($type = '', $input = array()) {
2222
try {
2323
switch ($type) {
2424
case 'stack' :
25+
if($input['region']) {
26+
if(!(isKeySet($input,'api_***') && isKeySet($input, 'access_token') && isKeySet($input, 'environment') && isKeySet($input, 'region')))
27+
$msg = 'Please provide valid api_***, access_token, environment and region';
28+
break;
29+
} else {
2530
if(!(isKeySet($input,'api_***') && isKeySet($input, 'access_token') && isKeySet($input, 'environment')))
2631
$msg = 'Please provide valid api_***, access_token and environment';
2732
break;
33+
}
34+
2835
case 'port' :
2936
if(isEmpty($input) || !is_numeric($input))
3037
$msg = 'Please provide valid string for '.$type;

0 commit comments

Comments
 (0)