Browse Source

Merge branch 'develop' of https://forge.laclic.fr/Laclic/CaracoleBundle into develop

packProduct
Fab 3 years ago
parent
commit
77b8983f24
7 changed files with 111 additions and 21 deletions
  1. +20
    -0
      Container/MyContainer.php
  2. +24
    -0
      Repository/AbstractRepositoryQuery.php
  3. +0
    -18
      Repository/Reminder/ReminderRepository.php
  4. +16
    -0
      Repository/Reminder/ReminderRepositoryQuery.php
  5. +32
    -0
      Repository/Reminder/ReminderStore.php
  6. +15
    -0
      Repository/RepositoryMerchantTrait.php
  7. +4
    -3
      Resolver/MerchantResolver.php

+ 20
- 0
Container/MyContainer.php View File

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

namespace Lc\CaracoleBundle\Container;

use Lc\CaracoleBundle\Resolver\MerchantResolver;

/**
* class MyContainer.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class MyContainer
{
public MerchantResolver $merchantResolver;

public function __construct(MerchantResolver $merchantResolver)
{
$this->merchantResolver = $merchantResolver;
}
}

+ 24
- 0
Repository/AbstractRepositoryQuery.php View File

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

namespace Lc\CaracoleBundle\Repository;

use Lc\SovBundle\Repository\AbstractRepositoryQuery as BaseAbstractRepositoryQuery;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\QueryBuilder;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Container\MyContainer;

abstract class AbstractRepositoryQuery extends BaseAbstractRepositoryQuery
{
public function __construct(
MyContainer $container,
ServiceEntityRepository $repository,
string $id,
PaginatorInterface $paginator = null
)
{
$this->container = $container;

parent::__construct($repository, $id, $paginator);
}
}

+ 0
- 18
Repository/Reminder/ReminderRepository.php View File

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

namespace Lc\CaracoleBundle\Repository\Reminder;

use Lc\CaracoleBundle\Repository\RepositoryTrait;
use Lc\SovBundle\Model\Reminder\ReminderInterface;
use Lc\SovBundle\Repository\Reminder\ReminderRepository as SovReminderRepository;

/**
* @method ReminderInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method ReminderInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method ReminderInterface[] findAll()
* @method ReminderInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ReminderRepository extends SovReminderRepository
{
use RepositoryTrait;
}

+ 16
- 0
Repository/Reminder/ReminderRepositoryQuery.php View File

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

namespace Lc\CaracoleBundle\Repository\Reminder;

use Lc\CaracoleBundle\Repository\RepositoryMerchantTrait;
use Lc\SovBundle\Repository\Reminder\ReminderRepositoryQuery as SovReminderRepositoryQuery;

/**
* class ReminderRepositoryQuery.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class ReminderRepositoryQuery extends SovReminderRepositoryQuery
{
use RepositoryMerchantTrait;
}

+ 32
- 0
Repository/Reminder/ReminderStore.php View File

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

namespace Lc\CaracoleBundle\Repository\Reminder;

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

/**
* class ReminderStore.
*
* @author Simon Vieille <simon@deblan.fr>
*/
class ReminderStore 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);
}
}

+ 15
- 0
Repository/RepositoryMerchantTrait.php View File

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

namespace Lc\CaracoleBundle\Repository;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;

trait RepositoryMerchantTrait
{
public function filterByMerchant(MerchantInterface $merchant)
{
return $this
->andWhere('.merchant = :merchant')
->setParameter(':merchant', $merchant);
}
}

+ 4
- 3
Resolver/MerchantResolver.php View File

@@ -46,9 +46,10 @@ class MerchantResolver
$request = $this->requestStack->getCurrentRequest();
$merchantRepository = $this->em->getRepository(MerchantInterface::class);
$merchants = $merchantRepository->findAll();
$isCli = php_sapi_name() === 'cli';

if ($request) {
if ($this->urlResolver->isServerLocalhost()) {
if ($request || $isCli) {
if ($isCli || $this->urlResolver->isServerLocalhost()) {
foreach ($merchants as $merchant) {
if ($merchant->getId() == $_ENV['CURRENT_MERCHANT_LOCAL']) {
$this->currentMerchant = $merchant;
@@ -102,4 +103,4 @@ class MerchantResolver
);
}

}
}

Loading…
Cancel
Save