Skip to content

Commit

Permalink
Add ModelManager::findMultiple()
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys committed Sep 29, 2020
1 parent 4c0c9bb commit e665bba
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Model/ModelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace Sonata\DoctrineORMAdminBundle\Model;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Util\ClassUtils;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\LockMode;
Expand Down Expand Up @@ -288,6 +290,21 @@ public function findOneBy($class, array $criteria = [])
return $this->getEntityManager($class)->getRepository($class)->findOneBy($criteria);
}

/**
* @return object[]&Collection all objects matching the given identifiers
*
* @phpstan-template T of object
* @phpstan-param class-string<T> $class
* @phpstan-return T[]
*/
public function findMultiple(string $class, array $ids): Collection
{
$proxyQuery = $this->createQuery($class);
$this->addIdentifiersToQuery($class, $proxyQuery, $ids);

return new ArrayCollection($this->executeQuery($proxyQuery));
}

/**
* @param string|object $class
*
Expand Down

0 comments on commit e665bba

Please sign in to comment.