Skip to content

Commit 27f8a65

Browse files
authored
Merge pull request #22 from contentstack/fix/psr4
Sync API feature support added
2 parents 94c8e0e + 89610e4 commit 27f8a65

21 files changed

+150
-64
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
## CHANGELOG
33
------------------------------------------------
44

5+
## Version 2.0.0
6+
###### Date: 02-Apr-2021
7+
### New Feature
8+
- Sync API support added
9+
### Enhancement
10+
- Added PSR 4 Standardized implementation.
11+
12+
------------------------------------------------
13+
514
## Version 1.8.1
615
###### Date: 17-Mar-2021
716
### Bug Fix

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,14 @@ To initialize the SDK, you will need to specify the API Key, Delivery Token, and
2424
use Contentstack\Contentstack;
2525
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME);
2626
```
27+
For Setting the European Region:
28+
If you want to set and use European region, refer to the code below:
2729

28-
30+
```php
31+
use Contentstack\Contentstack;
32+
use Contentstack\ContentstackRegion;
33+
$stack = Contentstack::Stack(API_KEY, DELIVERY_TOKEN, ENV_NAME, array('region'=> ContentstackRegion.EU));
34+
```
2935
#### Download and install library:
3036
To use the PHP SDK, you need to perform the following steps:
3137

composer.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
"require-dev": {
2828
"phpunit/phpunit": "^9.0",
2929
"phpunit/php-code-coverage": "^8.0",
30-
"sami/sami": "^4.1"
30+
"code-lts/doctum": "^5.3"
31+
},
32+
"scripts": {
33+
"generate:docs": "vendor/bin/doctum.php update ./config.php",
34+
"test": "vendor/bin/phpunit"
3135
},
3236
"require": {
3337
"php" : ">=5.5.0"

config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
22

3-
return new Sami\Sami('/Users/uttamukkoji/Documents/php/contentstack-php/src');
3+
return new Doctum\Doctum('./src');
44

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
define('ENTRIES', '/entries/');
2626
define('ASSETS', '/assets/');
2727
define('ENVIRONMENTS', '/environments/');
28+
define('SYNC', '/stacks/sync/');
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
use Contentstack\Stack\Stack;
1818

19-
require_once __DIR__ . '/lib/models/stack.php';
20-
2119
/**
2220
* Contentstack abstract class to provide access to Stack Object
2321
*
@@ -37,15 +35,15 @@ abstract class Contentstack
3735
* @param string $api_key : Contentstack Stack API KEY.
3836
* @param string $access_token : Contentstack Stack ACCESS TOKEN.
3937
* @param string $environment : Environment Name.
40-
* @param ContentstackRegion $region : Region name of Contentstack.
38+
* @param array $config : Stack Configuration to provide region.
4139
*
4240
* @return Stack
4341
* */
4442
public static function Stack($api_key = '',
4543
$access_token = '',
4644
$environment = '',
47-
$region = ''
45+
$config = array('region'=> '')
4846
) {
49-
return new Stack($api_key, $access_token, $environment, $region);
47+
return new Stack($api_key, $access_token, $environment, $config);
5048
}
5149
}
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,14 @@
1414
* @license https://github.com/contentstack/contentstack-php/blob/master/LICENSE.txt MIT Licence
1515
* @link https://pear.php.net/package/contentstack
1616
* */
17-
namespace Contentstack\Stack\Assets;
17+
namespace Contentstack\Stack;
1818

19-
require_once __DIR__ . "/../../Support/helper.php";
19+
require_once __DIR__ . "/../Support/helper.php";
2020

21-
use Contentstack\Stack\ContentType\Query\Query;
22-
use Contentstack\Stack\ContentType\BaseQuery\BaseQuery;
21+
use Contentstack\Stack\ContentType\Query;
22+
use Contentstack\Stack\BaseQuery;
2323
use Contentstack\Support\Utility;
2424

25-
26-
require_once __DIR__.'/query.php';
27-
require_once __DIR__."/base_query.php";
28-
require_once __DIR__."/../../Support/Utility.php";
29-
30-
3125
/**
3226
* Assets refer to all the media files (images, videos, PDFs,
3327
* audio files, and so on) uploaded in your Contentstack
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
* @link https://pear.php.net/package/contentstack
1515
* */
1616

17-
namespace Contentstack\Stack\ContentType\BaseQuery;
17+
namespace Contentstack\Stack;
1818
use Contentstack\Support\Utility;
1919

20-
require_once __DIR__ . "/../../Support/helper.php";
21-
require_once __DIR__."/../../Support/Utility.php";
20+
require_once __DIR__ . "/../Support/helper.php";
21+
2222
/**
2323
* BaseQuery
2424
* Base Class where all the Queries will be created
@@ -128,7 +128,7 @@ public function only($level = 'BASE', $field_uids = array())
128128
* */
129129
public function includeReference($field_uids = array())
130130
{
131-
if (is_array($field_uids)) {
131+
if ($field_uids && is_array($field_uids)) {
132132
$this->queryObject->_query = call_user_func(
133133
'contentstackReferences',
134134
'include',
@@ -465,7 +465,7 @@ public function skip($skip = 0)
465465
* */
466466
public function tags($tags = array())
467467
{
468-
if (is_array($tags)) {
468+
if ($tags && is_array($tags)) {
469469
$this->queryObject->_query = call_user_func(
470470
'contentstackTags',
471471
'tags',
@@ -508,7 +508,7 @@ public function limit($limit = '')
508508
* */
509509
public function containedIn($field = '', $value = array())
510510
{
511-
if (is_array($value)) {
511+
if ($value && is_array($value)) {
512512
$this->subQuery = call_user_func(
513513
'contentstackContains',
514514
'$in',
@@ -533,7 +533,7 @@ public function containedIn($field = '', $value = array())
533533
* */
534534
public function notContainedIn($field = '', $value = array())
535535
{
536-
if (is_array($value)) {
536+
if ($value && is_array($value)) {
537537
$this->subQuery = call_user_func(
538538
'contentstackContains',
539539
'$nin',
@@ -675,8 +675,8 @@ public function notEqualTo($field = '', $value = '')
675675
* */
676676
public function addQuery($_query = array())
677677
{
678-
if (is_array($_query)) {
679-
$this->subQuery = $_query;
678+
if ($_query && is_array($_query)) {
679+
$this->subQuery = json_encode($_query);
680680
return $this->queryObject;
681681
}
682682
throw contentstackCreateError("Provide valid query");

0 commit comments

Comments
 (0)