Explorar el Código

Correctig SectionResolver

feature/ticket
Guillaume hace 3 años
padre
commit
6db253f307
Se han modificado 2 ficheros con 10 adiciones y 6 borrados
  1. +1
    -1
      Repository/Section/SectionRepository.php
  2. +9
    -5
      Resolver/SectionResolver.php

+ 1
- 1
Repository/Section/SectionRepository.php Ver fichero

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Repository\Section;

use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Repository\AbstractRepository;
use Lc\CaracoleBundle\Repository\AbstractRepository;

/**
* @method SectionInterface|null find($id, $lockMode = null, $lockVersion = null)

+ 9
- 5
Resolver/SectionResolver.php Ver fichero

@@ -9,6 +9,7 @@ namespace Lc\CaracoleBundle\Resolver;
use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Resolver\UrlResolver;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Security;
@@ -18,9 +19,9 @@ class SectionResolver
protected $sectionRepository;
protected $merchantResolver;

public function __construct(MerchantResolver $merchantResolver, SectionRepository $sectionRepository)
public function __construct(MerchantResolver $merchantResolver, EntityManagerInterface $em)
{
$this->sectionRepository = $sectionRepository;
$this->em = $em;
$this->merchantResolver = $merchantResolver;
}

@@ -29,13 +30,16 @@ class SectionResolver
$currentAdminSection = null;
$userMerchant = $this->merchantResolver->getUserMerchant();

if($userMerchant!==null){
if ($userMerchant !== null) {
$currentAdminSection = $userMerchant->getCurrentAdminSection();
}

if($currentAdminSection === null){
$currentAdminSection = $this->sectionRepository->findOneBy(array('isDefault'=>true));
if ($currentAdminSection === null) {
$currentAdminSection = $this->em->getRepository(SectionInterface::class)->findOneBy(
array('isDefault' => true)
);
}

return $currentAdminSection;
}


Cargando…
Cancelar
Guardar