Skip to content

Commit 6fe3e0a

Browse files
Support Snippet feature
1 parent e3b42d5 commit 6fe3e0a

File tree

7 files changed

+29
-6
lines changed

7 files changed

+29
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ test/EntryTestReport.html
1111
test/Entryreport.html
1212
test/Entriesreport.html
1313
test/ImageTransformreport.html
14-
test/result.json
14+
test/result.json
15+
examples/index.php

src/config/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Contentstack\Config;
66

77
// Domain relevant constants
8-
define('HOST', 'cdn.contentstack.io');
8+
define('HOST', 'dev6-new-api.contentstack.io');
99
define('PROTOCOL', 'https');
1010
define('VERSION', '/v3');
1111
define('PORT', 443);

src/lib/models/base_query.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ public function includeContentType() {
215215
* @return Query
216216
* */
217217
public function includeCount() {
218+
// \Contentstack\Utility\debug($this->queryObject->_query);
218219
$this->queryObject->_query = call_user_func('contentstackAddBoolean', 'include_count', $this->queryObject->_query);
219220
return $this->queryObject;
220221
}

src/lib/models/content_type.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ public function Entry($entry_uid = '') {
3838
return new Entry($entry_uid, $this);
3939
}
4040

41+
/*
42+
* fetch
43+
* Fetch the specific contenttypes
44+
* */
45+
public function fetch($params) {
46+
$myArray = json_decode($params, true);
47+
$this->_query = $myArray;
48+
return \Contentstack\Utility\contentstackRequest($this);
49+
}
4150
/*
4251
* Query
4352
* Query object to create the "Query" on the specified ContentType

src/lib/models/query.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function __construct($data = '', $type = '') {
2525
$this->_query = array();
2626
$this->type = $type;
2727
parent::__construct($data, $this);
28+
2829

2930
}
3031

@@ -40,6 +41,7 @@ public function find() {
4041
return \Contentstack\Utility\contentstackRequest($this);
4142
}
4243
}
44+
4345

4446
/*
4547
* findOne

src/lib/models/stack.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
require_once __DIR__."/content_type.php";
99
require_once __DIR__."/assets.php";
10-
//require_once __DIR__."/asset.php";
1110
require_once __DIR__."/../../config/index.php";
1211

1312
/*
@@ -156,4 +155,10 @@ public function getAccessToken() {
156155
public function getEnvironment() {
157156
return $this->environment;
158157
}
158+
159+
public function getContentTypes($params) {
160+
$myArray = json_decode($params, true);
161+
$this->_query = $myArray;
162+
return \Contentstack\Utility\contentstackRequest($this, "getcontentTypes");
163+
}
159164
}

src/lib/utility.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ function getDomain($query) {
6565
if($query && isset($query->assets))
6666
$stack = $query->assets->stack;
6767
return $stack->getProtocol().'://'.$stack->getHost().':'.$stack->getPort().VERSION;
68+
6869
}
6970
}
7071

@@ -85,15 +86,18 @@ function contentstackUrl($queryObject = '', $type = '') {
8586
case 'get_last_activites':
8687
$URL = getDomain($queryObject).CONTENT_TYPES;
8788
break;
89+
case 'getcontentTypes':
90+
$URL = getDomain($queryObject).CONTENT_TYPES;
91+
break;
8892
case 'asset':
8993
$URL = getDomain($queryObject).ASSETS.$queryObject->assetUid;
9094
break;
9195
case 'assets':
9296
$URL = getDomain($queryObject).ASSETS;
9397
break;
9498
default:
95-
$URL = getDomain($queryObject).CONTENT_TYPES.$queryObject->contentType->uid.ENTRIES;
96-
if(isset($queryObject->entryUid)) $URL.=$queryObject->entryUid;
99+
$URL = getDomain($queryObject).CONTENT_TYPES.$queryObject->contentType->uid.ENTRIES;
100+
if(isset($queryObject->entryUid)) $URL.=$queryObject->entryUid;
97101
}
98102
$queryParams = generateQueryParams($queryObject);
99103
return $URL.'?'.$queryParams;
@@ -269,7 +273,8 @@ function contentstackRequest($queryObject = '', $type = ''){
269273
// receive server response ...
270274
curl_setopt($http, CURLOPT_RETURNTRANSFER, TRUE);
271275
$response = curl_exec($http);
272-
276+
277+
273278
// status code extraction
274279
$httpcode = curl_getinfo($http, CURLINFO_HTTP_CODE);
275280
//\Contentstack\Utility\debug(($httpcode));

0 commit comments

Comments
 (0)