From 862f325dcbff3405bf290cd4fe84430d328a6c4f Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Mon, 27 May 2019 13:48:27 +0300 Subject: [PATCH] nullable proxies --- src/Promise/PromiseMany.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Promise/PromiseMany.php b/src/Promise/PromiseMany.php index e81ed4333..c24fc45c1 100644 --- a/src/Promise/PromiseMany.php +++ b/src/Promise/PromiseMany.php @@ -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; } /** @@ -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; }