Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

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

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 4 additions & 3 deletions src/Contentstack.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ abstract class Contentstack
* @param string $access_token : Contentstack Stack ACCESS TOKEN.
* @param string $environment : Environment Name.
* @param array $config : Stack Configuration to provide region.
* @param ContentstackRegion $region : Region name of Contentstack.

* @param ContentstackRegion $region : Region name of Contentstack. (default region 'us')
*
* @return Stack
* */

public static function Stack($api_key = '',
$access_token = '',
$environment = '',
$config = array('region'=> '', 'branch'=> '', 'live_preview' => array('enable' => false, 'host' => 'api.contentstack.io'))
$config = array('region'=> 'us', 'branch'=> '', 'live_preview' => array('enable' => false, 'host' => 'api.contentstack.io'))
) {
return new Stack($api_key, $access_token, $environment, $config);
}
Expand Down
1 change: 1 addition & 0 deletions src/ContentstackRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ class ContentstackRegion
const EU= "eu";
const US= "us";
const AZURE_NA= "azure-na";
const AZURE_EU= "azure-eu";
}
26 changes: 25 additions & 1 deletion src/Stack/BaseQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,30 @@ public function includeCount()
return $this->queryObject;
}

/**
* To include the Metadata of entries based on the results
*
* @example
*
* use Contentstack\Contentstack;
* $stack = Contentstack::Stack("API_KEY", "DELIVERY_TOKEN", "ENVIRONMENT");
* $result = $stack->ContentType('product')->Query()->toJSON()->includeMetadata()->find();
*
* @return Query
* */


public function includeMetadata()
{
$this->queryObject->_query = call_user_func(
'contentstackAddBoolean',
'include_metadata',
$this->queryObject->_query
);
return $this->queryObject;
}


/**
* To get only count result
*
Expand Down Expand Up @@ -603,7 +627,7 @@ public function includeOwner()
*
* @return Query
* */
public function addParam($key = '', $value = '')
public function addParam($key = '', $value = '')
{
$this->queryObject->_query = call_user_func(
'contentstackAddParam',
Expand Down
5 changes: 3 additions & 2 deletions src/Stack/Stack.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ class Stack
* @param string $api_key - API Key of Stack
* @param string $delivery_token - Delivery Token of Stack
* @param string $environment - Environment Name of Stack
* @param string $region - API Key of Stack
* @param string $region - Region name of Contentstack. (default region 'us')
*
* */
public function __construct(
$api_key = '',
$delivery_token = '',
$environment = '',
$config = array('region'=> '', 'branch'=> '', 'live_preview' => array())
$config = array('region'=> 'us', 'branch'=> '', 'live_preview' => array())
) {
$previewHost = 'api.contentstack.io';
if ($config && $config !== "undefined" && array_key_exists('region', $config) && $config['region'] !== "undefined" && $config['region'] !== "us" ) {
Expand Down