findOneBy() public method

Finds a single document by a set of criteria.
public findOneBy ( array $criteria ) : object
$criteria array
return object
 /**
  * Performs an authentication
  * @param  array
  * @return Nette\Security\Identity
  * @throws Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($email, $password) = $credentials;
     $user = $this->adminRepository->findOneBy(['email' => $email]);
     if (!$user or !$this->passwordHasher->checkPassword($password, $user->getPassword())) {
         throw new NS\AuthenticationException("Invalid credentials", self::FAILURE);
     }
     return $user;
 }
 public function findOneBy(array $filters, $abort = true)
 {
     $entity = parent::findOneBy($filters);
     if (!$entity && $abort) {
         abort(404, $this->getMessageNotFound());
     }
     return $entity;
 }
Beispiel #3
0
 public function findOneById($id)
 {
     if (is_numeric($id)) {
         $item = parent::findOneBy(array("rdbms_id" => $id));
     } else {
         $item = parent::findOneById($id);
     }
     return $item;
 }
Beispiel #4
0
 public function findOneById($id)
 {
     if (strlen($id) == 24) {
         $user = parent::findOneById($id);
     } else {
         $user = parent::findOneBy(array("username" => $id));
     }
     return $user;
 }
 public function findOneById($id)
 {
     $qb = $this->createQueryBuilder('Project');
     if (strlen($id) == 24) {
         $project = parent::findOneById($id);
     } else {
         $project = parent::findOneBy(array("publicId" => $id));
     }
     return $project;
 }
 /**
  * {@inheritdoc}
  */
 public function findAuthCodeBy(array $criteria)
 {
     return $this->repository->findOneBy($criteria);
 }
Beispiel #7
0
 /**
  * Try to find similar resources
  *
  * @param \Bpi\ApiBundle\Domain\Repository\ResourceRepository $repository
  * @return array
  */
 public function findSimilar(\Doctrine\ODM\MongoDB\DocumentRepository $repository)
 {
     // @todo replace with query
     return $repository->findOneBy(array('resource.hash' => $this->hash, 'deleted' => false));
 }
 /**
  * {@inheritdoc}
  */
 public function findMappedStatement(array $criteria)
 {
     return parent::findOneBy($criteria);
 }
 /**
  * @param $projectionName
  * @param AggregateId $aggregateId
  * @return Projection
  */
 public function findById($projectionName, AggregateId $aggregateId)
 {
     $storedProjection = $this->repository->findOneBy(['projectionName' => (string) $projectionName, 'aggregateId' => (string) $aggregateId]);
     return empty($storedProjection) ? null : $storedProjection->getProjection();
 }
 public function findActivityBy(array $criteria = array())
 {
     return $this->repository->findOneBy($criteria);
 }
 /**
  * Finds a single AggregateRoot by a set of criteria.
  *
  * @param array $criteria
  *
  * @return AggregateRoot
  */
 protected function getOneBy(array $criteria)
 {
     return $this->documentRepository->findOneBy($criteria);
 }
Beispiel #12
0
 /**
  * @param string $eventName
  *
  * @return void
  */
 public function removeEvent($eventName)
 {
     if ($event = $this->repository->findOneBy(array('name' => $eventName, 'type' => 'event'))) {
         $this->repository->remove($event);
     }
 }
 /**
  * @inheritdoc
  */
 public function getFile($id)
 {
     return $this->repository->findOneBy(['shortId' => $id]);
 }