Scalr\Service\Aws\AbstractRepository::findOneBy PHP Метод

findOneBy() публичный Метод

Finds one element by required criteria.
public findOneBy ( array $criteria ) : object | null
$criteria array An assoc array with search query. It looks like array (propertyname => value)
Результат object | null Returns an entity or null if nothing found.
    public function findOneBy(array $criteria)
    {
        $em = $this->getEntityManager();
        $storage = $em->getStorage($this->getReflectionClassName());
        foreach ($storage as $obj) {
            $c = true;
            foreach ($criteria as $propertyName => $value) {
                $fn = 'get' . ucfirst($propertyName);
                if ($obj->{$fn}() !== $value) {
                    $c = false;
                    break;
                }
            }
            if ($c === true) {
                return $obj;
            }
        }
        return null;
    }