public function fetchOne(Persistence\Query $queryObject)
{
try {
return $queryObject->fetchOne($this);
} catch (NoResultException $e) {
return NULL;
} catch (NonUniqueResultException $e) {
// this should never happen!
throw new InvalidStateException("You have to setup your query calling ->setMaxResult(1).", 0, $e);
} catch (\Exception $e) {
throw $this->handleQueryException($e, $queryObject);
}
}
/** * @param QueryObject $listingsQuery * @return Listing|null * @throws ListingNotFoundException */ public function fetchListing(QueryObject $listingsQuery) { $listing = $this->listingsRepository->fetchOne($listingsQuery); if ($listing === null) { throw new ListingNotFoundException(); } return $listing; }