Skip to content

Commit a74ba93

Browse files
committed
Merge branch 'master' into feature/live-preview
2 parents 033dc03 + 7191eb4 commit a74ba93

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ test/ImageTransformreport.html
1313
examples/index.php
1414
.DS_Store
1515
tmp/
16-
stdout
17-
test/result.json
16+
test/result.json
17+
stdout

examples/index.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<html>
2+
<head>
3+
<title>Contentstack PHP SDK</title>
4+
</head>
5+
<body>
6+
<h1>Welcome to Contentstack PHP SDK</h1>
7+
</body>
8+
</html>
9+
<?php
10+
ini_set('display_errors', 'On');
11+
require_once __DIR__ . '/../src/contentstack.php';
12+
13+
use Contentstack\Contentstack;
14+
use Contentstack\Support\Utility;
15+
16+
$stack = Contentstack::Stack('', '', '');
17+
try {
18+
// \Contentstack\Utility\debug($stack);
19+
// $result = $stack->getContentTypes('{"include_snippet_schema": "false"}');
20+
// $result = $stack->ContentType('first_ct')->Query()->toJSON()->find();
21+
// $result = $stack->ContentType('a')->Fetch();
22+
// $result = $stack->ContentType('a')->Query()->includeSchema()->toJSON()->find();
23+
// $result = $stack->ContentType('ctwithallfields')->Query()->addParam('include_dimensions', true)->toJSON()->find();
24+
// $result = $stack->ContentType('a')->Entry('blta07130f8b344b260')->includeContentType()->toJSON()->fetch();
25+
$result = $stack->Assets()->Query()->includeFallback()->toJSON()->find();
26+
//$result = $stack->Assets('blt9b5825dd804a9067')->addParam('include_dimension', 'true')->fetch();
27+
Utility::debug(($result));
28+
29+
} catch(Exception $e) {
30+
echo "Message : ".$e->getMessage(); // returns message -> API -> error_message
31+
echo "Code : ".$e->getCode(); // returns number -> API -> error_code
32+
echo "Errors : ".print_r($e->getErrors()); // returns array -> API -> errors
33+
}

src/Stack/Stack.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ public function ImageTrasform($url, $parameters)
137137
}
138138
}
139139

140-
141140
public function LivePreviewQuery($parameters) {
142141
$this->live_preview['live_preview'] = $parameters['live_preview'] ?? 'init';
143142
$this->live_preview['content_type_uid'] = $parameters['content_type_uid'];
@@ -292,7 +291,6 @@ public function getEnvironment()
292291
return $this->environment;
293292
}
294293

295-
296294
/**
297295
* This function sets Branch.
298296
*

src/Support/Utility.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public static function isLivePreview($query) {
105105
}
106106
return false;
107107
}
108+
108109
/**
109110
* Get the domain from the current object
110111
*
@@ -129,7 +130,7 @@ public static function getDomain($query)
129130
$host = $stack->live_preview['host'];
130131
}
131132
return $stack->getProtocol()
132-
.'://'.$host
133+
.'://'.$stack->getHost()
133134
.':'
134135
.$stack->getPort().VERSION;
135136
}

test/EntriesTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public static function setUpBeforeClass() : void {
2424
if (self::$rest->getHost() !== NULL) {
2525
self::$Stack->setHost(self::$rest->getHost());
2626
}
27-
2827
self::$LivePreviewStack = Contentstack::Stack(self::$rest->getAPIKEY(), self::$rest->getAccessToken(), self::$rest->getEnvironmentName(), array('live_preview' => array(
2928
'enable'=> true,
3029
'host' => 'preview.contentstack.com',

test/constants.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111

1212

1313
// fpr query test params
14+
define('CT_REF', 'reference');
1415
define('CT_ContentType', 'ctwithallfields');

0 commit comments

Comments
 (0)