Skip to content

Commit 5ac511b

Browse files
Updated php-sdk
1 parent 64a9a20 commit 5ac511b

File tree

4 files changed

+55
-16
lines changed

4 files changed

+55
-16
lines changed

src/lib/models/assets.php

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
* */
55
namespace Contentstack\Stack\Assets;
66

7-
use Contentstack\Stack\Assets\QueryAssets\QueryAssets;
7+
8+
use Contentstack\Stack\ContentType\BaseQuery\BaseQuery;
89
use Contentstack\Stack\ContentType\Query\Query;
910
use Contentstack\Utility;
1011

@@ -14,24 +15,53 @@
1415
/*
1516
* Class Assets
1617
* */
17-
class Assets {
18+
class Assets extends BaseQuery {
19+
20+
var $operation;
21+
var $assetUid = '';
22+
var $stack = '';
23+
var $type = '';
24+
1825

19-
var $stack = '';
20-
2126

2227
/*
23-
* Assets
24-
* Assets Class to initalize your Assets
28+
*
29+
* Assets constructor
2530
* @param
2631
*
2732
* */
28-
public function __construct($stack = '') {
33+
public function __construct($asset_uid = '', $stack = '') {
34+
2935
$this->stack = $stack;
30-
$this->type = 'assets';
36+
if($asset_uid == ''){
37+
$this->type = 'assets';
38+
}else{
39+
$this->type = 'asset';
40+
41+
}
42+
$this->assetUid = $asset_uid;
43+
parent::__construct($this, $assetUid);
44+
3145
}
3246

47+
/*
48+
* Query
49+
* Query object to create the "Query" on the specified ContentType
50+
* @returns Query
51+
* */
3352
public function Query() {
3453
return new Query($this, $this->type);
3554
}
3655

56+
57+
/*
58+
* fetch
59+
* Fetch the specified assets
60+
* */
61+
public function fetch() {
62+
$this->operation = __FUNCTION__;
63+
return \Contentstack\Utility\request($this, 'asset');
64+
}
65+
66+
3767
}

src/lib/models/base_query.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ public function __construct($data = '', $parent = '') {
2222
}else if ($data->type == 'asset'){
2323

2424
$this->asset = $data;
25-
$this->queryObject = $data;
25+
$this->queryObject = $parent;
2626
$this->queryObject->_query = array();
2727
$this->subQuery = array();
2828

29-
}else{
29+
}
30+
else{
3031
$this->contentType = $data;
3132
$this->queryObject = $parent;
3233
$this->queryObject->_query = array();

src/lib/models/query.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public function find() {
4848
public function findOne() {
4949
$this->operation = __FUNCTION__;
5050
$this->_query['limit'] = 1;
51-
return Utility\request($this);
51+
if($this->type == 'assets'){
52+
return Utility\request($this, 'assets');
53+
}else if($this->type == 'contentType'){
54+
return Utility\request($this);
55+
}
56+
5257
}
5358
}

src/lib/models/stack.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@ public function ContentType($contentTypeId = '') {
4747
return new ContentType($contentTypeId, $this);
4848
}
4949

50-
public function Assets(){
51-
return new Assets($this);
52-
}
5350

54-
public function Asset($assetUid = '') {
55-
return new Asset($assetUid, $this);
51+
/*
52+
* Assets
53+
* Assets Class to initalize your Assets
54+
* @param
55+
*
56+
* */
57+
public function Assets($assetUid = '') {
58+
return new Assets($assetUid, $this);
5659
}
5760

5861
/*

0 commit comments

Comments
 (0)