Charly 3 лет назад
Родитель
Сommit
d27579a01a
6 измененных файлов: 118 добавлений и 30 удалений
  1. +0
    -2
      Repository/Reminder/ReminderStore.php
  2. +0
    -27
      Repository/Reminder/TicketStore.php
  3. +0
    -1
      Repository/Ticket/TicketRepositoryQuery.php
  4. +51
    -0
      Repository/Ticket/TicketStore.php
  5. +40
    -0
      Repository/User/UserRepositoryQuery.php
  6. +27
    -0
      Repository/User/UserStore.php

+ 0
- 2
Repository/Reminder/ReminderStore.php Просмотреть файл

@@ -2,8 +2,6 @@

namespace Lc\CaracoleBundle\Repository\Reminder;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\CaracoleBundle\Repository\SectionStoreTrait;
use Lc\SovBundle\Model\User\UserInterface;

+ 0
- 27
Repository/Reminder/TicketStore.php Просмотреть файл

@@ -1,27 +0,0 @@
<?php

namespace Lc\CaracoleBundle\Repository\Reminder;

use Lc\SovBundle\Repository\Reminder\ReminderStore as SovReminderStore;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;

class TicketStore extends SovReminderStore
{
protected MerchantInterface $merchant;

public function setMerchant(MerchantInterface $merchant)
{
$this->merchant = $merchant;
}

public function getFoo($query = null)
{
$query = $this->query->create();

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getFoo($query);
}
}

+ 0
- 1
Repository/Ticket/TicketRepositoryQuery.php Просмотреть файл

@@ -8,5 +8,4 @@ use Lc\SovBundle\Repository\Ticket\TicketRepositoryQuery as SovTicketRepositoryQ
class TicketRepositoryQuery extends SovTicketRepositoryQuery
{
use MerchantRepositoryQueryTrait;

}

+ 51
- 0
Repository/Ticket/TicketStore.php Просмотреть файл

@@ -0,0 +1,51 @@
<?php

namespace Lc\CaracoleBundle\Repository\Ticket;

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\Ticket\TicketStore as SovTicketStore;

class TicketStore extends SovTicketStore
{
use MerchantStoreTrait;

public function getByUser($user, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getByUser($user, $query);
}

public function getAllOpen(int $limit = 0, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::getAllOpen($limit, $query);
}

public function countAllOpen($query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query->filterByMerchant($this->merchant);
}

return parent::countAllOpen($query);
}

}

+ 40
- 0
Repository/User/UserRepositoryQuery.php Просмотреть файл

@@ -0,0 +1,40 @@
<?php

namespace Lc\CaracoleBundle\Repository\User;

use App\Entity\Merchant\Merchant;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\SovBundle\Repository\User\UserRepositoryQuery as SovUserRepositoryQuery;

class UserRepositoryQuery extends SovUserRepositoryQuery
{
use MerchantRepositoryQueryTrait;

protected $isJoinUserMerchants = false;

public function joinUserMerchants(): self
{
if (!$this->isJoinUserMerchants) {
$this->isJoinUserMerchants = true;

return $this
->innerJoin('.userMerchants', 'um');
}
return $this;
}

public function filterMerchantIsActive(): self
{
$this->joinUserMerchants();
return $this
->andWhere('um.active = 1');
}

public function filterByUserMerchant(Merchant $merchant): self
{
$this->joinUserMerchants();
return $this
->andWhere('um.merchant = :merchant')
->setParameter('merchant', $merchant);
}
}

+ 27
- 0
Repository/User/UserStore.php Просмотреть файл

@@ -0,0 +1,27 @@
<?php

namespace Lc\CaracoleBundle\Repository\User;

use App\Entity\Newsletter\Newsletter;
use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Repository\User\UserStore as SovUserStore;

class UserStore extends SovUserStore
{
use MerchantStoreTrait;

public function getByNewsletter(Newsletter $newsletter, $query = null): array
{
if (is_null($query)) {
$query = $this->query->create();
}

if ($this->merchant) {
$query
->filterByUserMerchant($this->merchant)
->filterMerchantIsActive();
}

return parent::getByNewsletter($newsletter, $query);
}
}

Загрузка…
Отмена
Сохранить