1 | <?php |
||
2 | /** |
||
3 | * Cycle DataMapper ORM |
||
4 | * |
||
5 | * @license MIT |
||
6 | * @author Anton Titov (Wolfy-J) |
||
7 | */ |
||
8 | declare(strict_types=1); |
||
9 | |||
10 | namespace Cycle\ORM\Promise\Collection; |
||
11 | |||
12 | use Cycle\ORM\Promise\PromiseInterface; |
||
13 | use Doctrine\Common\Collections\AbstractLazyCollection; |
||
14 | use Doctrine\Common\Collections\ArrayCollection; |
||
15 | |||
16 | /** |
||
17 | * LazyLoading collection build at top of data promise. |
||
18 | */ |
||
19 | class CollectionPromise extends AbstractLazyCollection implements CollectionPromiseInterface |
||
20 | { |
||
21 | /** @var PromiseInterface */ |
||
22 | protected $promise; |
||
23 | |||
24 | /** |
||
25 | * @param PromiseInterface $promise |
||
26 | */ |
||
27 | public function __construct(PromiseInterface $promise) |
||
28 | { |
||
29 | $this->promise = $promise; |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * @inheritdoc |
||
34 | */ |
||
35 | public function getPromise(): PromiseInterface |
||
36 | { |
||
37 | return $this->promise; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @inheritdoc |
||
42 | */ |
||
43 | protected function doInitialize() |
||
44 | { |
||
45 | $this->collection = new ArrayCollection($this->promise->__resolve()); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
46 | } |
||
47 | } |