Charly 3 роки тому
джерело
коміт
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);
}
}

Завантаження…
Відмінити
Зберегти