Browse Source

Refactoring repositoryQuery id d'entité

develop
Fabien Normand 3 years ago
parent
commit
45e7d63d5a
12 changed files with 21 additions and 21 deletions
  1. +1
    -1
      Repository/File/FileRepositoryQuery.php
  2. +1
    -1
      Repository/Newsletter/NewsletterRepositoryQuery.php
  3. +3
    -3
      Repository/Reminder/ReminderRepositoryQuery.php
  4. +1
    -1
      Repository/Setting/SiteSettingRepositoryQuery.php
  5. +1
    -1
      Repository/Site/NewsRepositoryQuery.php
  6. +1
    -1
      Repository/Site/PageRepositoryQuery.php
  7. +1
    -1
      Repository/Site/SiteRepositoryQuery.php
  8. +1
    -1
      Repository/Ticket/TicketMessageRepositoryQuery.php
  9. +5
    -5
      Repository/Ticket/TicketRepositoryQuery.php
  10. +1
    -1
      Repository/Ticket/TicketStore.php
  11. +2
    -2
      Repository/User/GroupUserRepositoryQuery.php
  12. +3
    -3
      Repository/User/UserRepositoryQuery.php

+ 1
- 1
Repository/File/FileRepositoryQuery.php View File

{ {
public function __construct(FileRepository $repository, PaginatorInterface $paginator) public function __construct(FileRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'file', $paginator);
} }
} }

+ 1
- 1
Repository/Newsletter/NewsletterRepositoryQuery.php View File

{ {
public function __construct(NewsletterRepository $repository, PaginatorInterface $paginator) public function __construct(NewsletterRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'newsletter', $paginator);
} }
} }

+ 3
- 3
Repository/Reminder/ReminderRepositoryQuery.php View File



public function __construct(ReminderRepository $repository, PaginatorInterface $paginator) public function __construct(ReminderRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'reminder', $paginator);
} }


public function filterByDone($done = false): self public function filterByDone($done = false): self
$this->isJoinUser = true; $this->isJoinUser = true;


return $this return $this
->leftJoin('.users', 'u');
->leftJoin('.users', 'users');
} }
return $this; return $this;
} }
{ {
$this->joinUser(); $this->joinUser();
return $this return $this
->having('COUNT(u.id) = 0')
->having('COUNT(users.id) = 0')
->orHaving(':user MEMBER OF .users') ->orHaving(':user MEMBER OF .users')
->setParameter(':user', $user); ->setParameter(':user', $user);
} }

+ 1
- 1
Repository/Setting/SiteSettingRepositoryQuery.php View File

{ {
public function __construct(SiteSettingRepository $repository, PaginatorInterface $paginator) public function __construct(SiteSettingRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'siteSetting', $paginator);
} }
} }

+ 1
- 1
Repository/Site/NewsRepositoryQuery.php View File



public function __construct(NewsRepository $repository, PaginatorInterface $paginator) public function __construct(NewsRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'news', $paginator);
} }
} }

+ 1
- 1
Repository/Site/PageRepositoryQuery.php View File

{ {
public function __construct(PageRepository $repository, PaginatorInterface $paginator) public function __construct(PageRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'page', $paginator);
} }


} }

+ 1
- 1
Repository/Site/SiteRepositoryQuery.php View File

{ {
public function __construct(SiteRepository $repository, PaginatorInterface $paginator) public function __construct(SiteRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'site', $paginator);
} }
} }

+ 1
- 1
Repository/Ticket/TicketMessageRepositoryQuery.php View File

{ {
public function __construct(TicketMessageRepository $repository, PaginatorInterface $paginator) public function __construct(TicketMessageRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'ticketMessage', $paginator);
} }


public function filterByTicket(TicketInterface $ticket) public function filterByTicket(TicketInterface $ticket)

+ 5
- 5
Repository/Ticket/TicketRepositoryQuery.php View File



public function __construct(TicketRepository $repository, PaginatorInterface $paginator) public function __construct(TicketRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'ticket', $paginator);
} }


public function filterByUser(UserInterface $user): self public function filterByUser(UserInterface $user): self
$this->joinUser(); $this->joinUser();


return $this return $this
->andWhere('.visitorFirstname LIKE :firstname OR u.firstname LIKE :firstname')
->andWhere('.visitorFirstname LIKE :firstname OR user.firstname LIKE :firstname')
->setParameter('firstname', $firstname); ->setParameter('firstname', $firstname);
} }


$this->joinUser(); $this->joinUser();


return $this return $this
->andWhere('.visitorLastname LIKE :lastname OR u.lastname LIKE :lastname')
->andWhere('.visitorLastname LIKE :lastname OR user.lastname LIKE :lastname')
->setParameter('lastname', $lastname); ->setParameter('lastname', $lastname);
} }


$this->joinUser(); $this->joinUser();


return $this return $this
->andWhere('.visitorEmail LIKE :email OR u.email LIKE :email')
->andWhere('.visitorEmail LIKE :email OR user.email LIKE :email')
->setParameter('email', $email); ->setParameter('email', $email);
} }


public function selectCount(): self public function selectCount(): self
{ {
return $this return $this
->select('count(r.id) as count');
->select('count(ticket.id) as count');
} }
} }

+ 1
- 1
Repository/Ticket/TicketStore.php View File

$query $query
->filterByStatus(Ticket::TICKET_STATUS_OPEN) ->filterByStatus(Ticket::TICKET_STATUS_OPEN)
->limit($limit) ->limit($limit)
->orderBy('r.id', 'DESC');
->orderBy('.id', 'DESC');


return $query->find(); return $query->find();
} }

+ 2
- 2
Repository/User/GroupUserRepositoryQuery.php View File

{ {
public function __construct(GroupUserRepository $repository, PaginatorInterface $paginator) public function __construct(GroupUserRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'groupUser', $paginator);
} }


protected $isJoinUsers = false; protected $isJoinUsers = false;
if (!$this->isJoinUsers) { if (!$this->isJoinUsers) {
$this->isJoinUsers = true; $this->isJoinUsers = true;
return $this return $this
->innerJoin('.users', 'user');
->innerJoin('.users', 'users');
} }
return $this; return $this;
} }

+ 3
- 3
Repository/User/UserRepositoryQuery.php View File

{ {
public function __construct(UserRepository $repository, PaginatorInterface $paginator) public function __construct(UserRepository $repository, PaginatorInterface $paginator)
{ {
parent::__construct($repository, 'r', $paginator);
parent::__construct($repository, 'user', $paginator);
} }


protected $isJoinGroupUsers = false; protected $isJoinGroupUsers = false;
if (!$this->isJoinGroupUsers) { if (!$this->isJoinGroupUsers) {
$this->isJoinGroupUsers = true; $this->isJoinGroupUsers = true;


$this->innerJoin('.groupUsers', 'groupUser');
$this->innerJoin('.groupUsers', 'groupUsers');
if($addSelect){ if($addSelect){
$this->addSelect('groupUser');
$this->addSelect('groupUsers');
} }
} }
return $this; return $this;

Loading…
Cancel
Save