Skip to content

Commit f30c743

Browse files
made changes in global fields
1 parent 6fe3e0a commit f30c743

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

src/lib/models/base_query.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ public function exists($field_uid = '') {
183183
* */
184184
public function includeSchema() {
185185
$this->queryObject->_query = call_user_func('contentstackAddBoolean', 'include_schema', $this->queryObject->_query);
186+
186187
return $this->queryObject;
187188
}
188189

src/lib/models/content_type.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Contentstack\Stack\ContentType\Entry\Entry;
88
use Contentstack\Stack\ContentType\Query\Query;
9+
//use Contentstack\Stack\ContentType\Query\Fetch;
910

1011
require_once __DIR__.'/entry.php';
1112
require_once __DIR__.'/query.php';
@@ -14,6 +15,7 @@
1415
* Class ContentType
1516
* */
1617
class ContentType {
18+
1719
var $uid = '';
1820
var $stack = '';
1921

@@ -42,9 +44,11 @@ public function Entry($entry_uid = '') {
4244
* fetch
4345
* Fetch the specific contenttypes
4446
* */
45-
public function fetch($params) {
46-
$myArray = json_decode($params, true);
47-
$this->_query = $myArray;
47+
public function Fetch($params = null) {
48+
if($params) {
49+
$myArray = json_decode($params, true);
50+
$this->_query = $myArray;
51+
}
4852
return \Contentstack\Utility\contentstackRequest($this);
4953
}
5054
/*
@@ -53,6 +57,7 @@ public function fetch($params) {
5357
* @returns Query
5458
* */
5559
public function Query() {
60+
\Contentstack\Utility\debug(("sndkcxcx cx n"));
5661
return new Query($this, $this->type);
5762
}
5863
}

src/lib/utility.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,18 @@ function contentstackUrl($queryObject = '', $type = '') {
9696
$URL = getDomain($queryObject).ASSETS;
9797
break;
9898
default:
99-
$URL = getDomain($queryObject).CONTENT_TYPES.$queryObject->contentType->uid.ENTRIES;
99+
100+
if($queryObject->_query && $queryObject->_query['include_global_field_schema'] || !$queryObject->contentType) {
101+
$URL = getDomain($queryObject).CONTENT_TYPES.$queryObject->uid;
102+
} else {
103+
$URL = getDomain($queryObject).CONTENT_TYPES.$queryObject->contentType->uid.ENTRIES;
104+
}
100105
if(isset($queryObject->entryUid)) $URL.=$queryObject->entryUid;
101106
}
107+
102108
$queryParams = generateQueryParams($queryObject);
109+
// \Contentstack\Utility\debug(($URL));
110+
// \Contentstack\Utility\debug(($queryParams));
103111
return $URL.'?'.$queryParams;
104112

105113
}
@@ -218,6 +226,10 @@ function wrapResult($result = '', $queryObject = '') {
218226
$wrapper = (!$flag) ? new Result($result['entry']) : $result['entry'];
219227
if(isKeySet($result, 'asset'))
220228
$wrapper = (!$flag) ? new Result($result['asset']) : $result['asset'];
229+
if(\Contentstack\Utility\isKeySet($result, 'schema'))
230+
array_push($wrapper, $result['schema']);
231+
if(\Contentstack\Utility\isKeySet($result, 'content_type'))
232+
array_push($wrapper, $result['content_type']);
221233
break;
222234
case 'find':
223235
$wrapper = array();
@@ -273,7 +285,6 @@ function contentstackRequest($queryObject = '', $type = ''){
273285
// receive server response ...
274286
curl_setopt($http, CURLOPT_RETURNTRANSFER, TRUE);
275287
$response = curl_exec($http);
276-
277288

278289
// status code extraction
279290
$httpcode = curl_getinfo($http, CURLINFO_HTTP_CODE);

0 commit comments

Comments
 (0)