Skip to content

Commit

Permalink
Merge pull request #72 from cycle/collection-selectable-promise
Browse files Browse the repository at this point in the history
Add Selectable implementation
  • Loading branch information
wolfy-j committed Feb 12, 2020
2 parents e1ce3b1 + b6c18d5 commit f144d1f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Promise/Collection/CollectionPromise.php
Expand Up @@ -14,11 +14,13 @@
use Cycle\ORM\Promise\PromiseInterface;
use Doctrine\Common\Collections\AbstractLazyCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\Selectable;

/**
* LazyLoading collection build at top of data promise.
*/
class CollectionPromise extends AbstractLazyCollection implements CollectionPromiseInterface
class CollectionPromise extends AbstractLazyCollection implements CollectionPromiseInterface, Selectable
{
/** @var PromiseInterface */
protected $promise;
Expand Down Expand Up @@ -46,4 +48,14 @@ protected function doInitialize(): void
{
$this->collection = new ArrayCollection($this->promise->__resolve());
}

/**
* @inheritDoc
*/
public function matching(Criteria $criteria)
{
$this->initialize();

return $this->collection->matching($criteria);
}
}

0 comments on commit f144d1f

Please sign in to comment.