Skip to content

Commit

Permalink
nullable proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy-j committed May 27, 2019
1 parent 438221b commit 862f325
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Promise/PromiseMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(ORMInterface $orm, string $target, array $query = []
*/
public function __loaded(): bool
{
return empty($this->orm);
return $this->orm === null;
}

/**
Expand Down Expand Up @@ -78,6 +78,12 @@ public function __resolve()
return $this->resolved;
}

if ($this->query === []) {
// nothing to proxy to
$this->orm = null;
return null;
}

foreach ($this->orm->getRepository($this->target)->findAll($this->query + $this->where) as $item) {
$this->resolved[] = $item;
}
Expand Down

0 comments on commit 862f325

Please sign in to comment.