Skip to content

Commit

Permalink
fix expand attacing on AbstractQuery, fix readme example
Browse files Browse the repository at this point in the history
  • Loading branch information
tooyz committed Aug 10, 2017
1 parent af2c498 commit 405fe0e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ $counterparty = $counterparty->buildUpdate()
```
Product::query($sklad, QuerySpecs::create([
'maxResults' => 25,
'expand' => Expand::create([Employee::class]),
'expand' => Expand::create([Employee::$entityName]),
'updatedFrom' => new CommonDate("2017-01-01"),
'updatedBy' => "admin@admin"
]))->getList();
Expand Down
6 changes: 4 additions & 2 deletions src/Components/Query/AbstractQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract class AbstractQuery{
/**
* @var Expand $expand
*/
private $expand;
protected $expand = null;
private $customQueryUrl = null;
protected static $entityListClass;

Expand Down Expand Up @@ -71,7 +71,9 @@ public function setRequestOptions(RequestConfig $options){
* @return QuerySpecs
*/
protected function attachExpand(QuerySpecs &$querySpecs){
$querySpecs->expand = $this->expand;
if ( $this->expand !== null ){
$querySpecs->expand = $this->expand;
}
return $querySpecs;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Components/Query/EntityQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ class EntityQuery extends AbstractQuery {
/**
* Get entity by id
* @param $id
* @param Expand|null $expand
* @param Expand|null $expand Deprecated, use withExpand()
* @return AbstractEntity
*/
public function byId($id, Expand $expand = null){
if ( !$expand ) $expand = $this->expand;
$res = $this->getSkladInstance()->getClient()->get(
ApiUrlRegistry::instance()->getByIdUrl($this->entityName, $id),
($expand?['expand'=>$expand->flatten()]:[]),
Expand Down

0 comments on commit 405fe0e

Please sign in to comment.