@@ -5,6 +5,9 @@ namespace Lc\SovBundle\Repository; | |||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; | |||
use Doctrine\ORM\QueryBuilder; | |||
use Knp\Component\Pager\PaginatorInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Doctrine\EntityInterface; | |||
abstract class AbstractRepositoryQuery | |||
{ | |||
@@ -52,14 +55,14 @@ abstract class AbstractRepositoryQuery | |||
public function count(): string | |||
{ | |||
return $this->query->getQuery() | |||
->getSingleScalarResult(); | |||
->getSingleScalarResult(); | |||
} | |||
public function findOne() | |||
public function findOne(): ?EntityInterface | |||
{ | |||
return $this->query->getQuery() | |||
->setMaxResults(1) | |||
->getOneOrNullResult(); | |||
->setMaxResults(1) | |||
->getOneOrNullResult(); | |||
} | |||
public function find(): array | |||
@@ -133,7 +136,5 @@ abstract class AbstractRepositoryQuery | |||
->setParameter('slug', $slug); | |||
} | |||
} | |||
@@ -6,9 +6,12 @@ use Lc\SovBundle\Model\Site\PageInterface; | |||
abstract class AbstractStore | |||
{ | |||
public function createQuery() | |||
public function createQuery($query = null) | |||
{ | |||
return $this->query->create(); | |||
if (is_null($query)) { | |||
$query = $this->query->create(); | |||
} | |||
return $query; | |||
} | |||
public function getRepositoryQuery() | |||
@@ -24,23 +27,4 @@ abstract class AbstractStore | |||
return $query->findOne(); | |||
} | |||
public function getOneByDevAlias(string $devAlias) | |||
{ | |||
$query = $this->query->create(); | |||
$query->filterByDevAlias($devAlias); | |||
return $query->findOne(); | |||
} | |||
//findPageBySlug | |||
public function getOneBySlug(string $slug): ?PageInterface | |||
{ | |||
$query = $this->query->create(); | |||
$query->filterBySlug($slug); | |||
return $query->findOne(); | |||
} | |||
} |
@@ -4,6 +4,7 @@ namespace Lc\SovBundle\Repository\Ticket; | |||
use App\Entity\Ticket\Ticket; | |||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Repository\AbstractStore; | |||
class TicketStore extends AbstractStore implements TicketStoreInterface | |||
@@ -16,10 +17,10 @@ class TicketStore extends AbstractStore implements TicketStoreInterface | |||
} | |||
// getTicketsByUser | |||
public function getByUser($user, $query = null): array | |||
public function getByUser(UserInterface $user, $query = null): array | |||
{ | |||
if (is_null($query)) { | |||
$query = $this->query->create(); | |||
$query = $this->createQuery(); | |||
} | |||
$query->filterByUser($user); |
@@ -21,8 +21,7 @@ class UserStore extends AbstractStore implements UserStoreInterface | |||
$query = $this->query->create(); | |||
} | |||
$query | |||
->filterByNewsletter($newsletter); | |||
$query->filterByNewsletter($newsletter); | |||
return $query->find(); | |||
} |