Skip to content

Commit 1e9adae

Browse files
Added 'include_matadata' and set default region to 'us' (#33)
* Added 'include_matadata' and set default region to 'us' * Updated License file * Removed duplicate line
1 parent 1f78f7e commit 1e9adae

File tree

5 files changed

+34
-7
lines changed

5 files changed

+34
-7
lines changed

LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2012-2022 Contentstack (http://app.contentstack.com). All Rights Reserved
3+
Copyright (c) 2012-2023 Contentstack (http://app.contentstack.com). All Rights Reserved
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/Contentstack.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ abstract class Contentstack
3939
* @param string $access_token : Contentstack Stack ACCESS TOKEN.
4040
* @param string $environment : Environment Name.
4141
* @param array $config : Stack Configuration to provide region.
42-
* @param ContentstackRegion $region : Region name of Contentstack.
43-
42+
* @param ContentstackRegion $region : Region name of Contentstack. (default region 'us')
43+
*
4444
* @return Stack
4545
* */
46+
4647
public static function Stack($api_key = '',
4748
$access_token = '',
4849
$environment = '',
49-
$config = array('region'=> '', 'branch'=> '', 'live_preview' => array('enable' => false, 'host' => 'api.contentstack.io'))
50+
$config = array('region'=> 'us', 'branch'=> '', 'live_preview' => array('enable' => false, 'host' => 'api.contentstack.io'))
5051
) {
5152
return new Stack($api_key, $access_token, $environment, $config);
5253
}

src/ContentstackRegion.php

+1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ class ContentstackRegion
3030
const EU= "eu";
3131
const US= "us";
3232
const AZURE_NA= "azure-na";
33+
const AZURE_EU= "azure-eu";
3334
}

src/Stack/BaseQuery.php

+25-1
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,30 @@ public function includeCount()
546546
return $this->queryObject;
547547
}
548548

549+
/**
550+
* To include the Metadata of entries based on the results
551+
*
552+
* @example
553+
*
554+
* use Contentstack\Contentstack;
555+
* $stack = Contentstack::Stack("API_KEY", "DELIVERY_TOKEN", "ENVIRONMENT");
556+
* $result = $stack->ContentType('product')->Query()->toJSON()->includeMetadata()->find();
557+
*
558+
* @return Query
559+
* */
560+
561+
562+
public function includeMetadata()
563+
{
564+
$this->queryObject->_query = call_user_func(
565+
'contentstackAddBoolean',
566+
'include_metadata',
567+
$this->queryObject->_query
568+
);
569+
return $this->queryObject;
570+
}
571+
572+
549573
/**
550574
* To get only count result
551575
*
@@ -603,7 +627,7 @@ public function includeOwner()
603627
*
604628
* @return Query
605629
* */
606-
public function addParam($key = '', $value = '')
630+
public function addParam($key = '', $value = '')
607631
{
608632
$this->queryObject->_query = call_user_func(
609633
'contentstackAddParam',

src/Stack/Stack.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ class Stack
4949
* @param string $api_key - API Key of Stack
5050
* @param string $delivery_token - Delivery Token of Stack
5151
* @param string $environment - Environment Name of Stack
52-
* @param string $region - API Key of Stack
52+
* @param string $region - Region name of Contentstack. (default region 'us')
53+
*
5354
* */
5455
public function __construct(
5556
$api_key = '',
5657
$delivery_token = '',
5758
$environment = '',
58-
$config = array('region'=> '', 'branch'=> '', 'live_preview' => array())
59+
$config = array('region'=> 'us', 'branch'=> '', 'live_preview' => array())
5960
) {
6061
$previewHost = 'api.contentstack.io';
6162
if ($config && $config !== "undefined" && array_key_exists('region', $config) && $config['region'] !== "undefined" && $config['region'] !== "us" ) {

0 commit comments

Comments
 (0)