Browse Source

Correctig SectionResolver

feature/ticket
Guillaume 3 years ago
parent
commit
6db253f307
2 changed files with 10 additions and 6 deletions
  1. +1
    -1
      Repository/Section/SectionRepository.php
  2. +9
    -5
      Resolver/SectionResolver.php

+ 1
- 1
Repository/Section/SectionRepository.php View File

namespace Lc\CaracoleBundle\Repository\Section; namespace Lc\CaracoleBundle\Repository\Section;


use Lc\CaracoleBundle\Model\Section\SectionInterface; 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) * @method SectionInterface|null find($id, $lockMode = null, $lockVersion = null)

+ 9
- 5
Resolver/SectionResolver.php View File

use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface; use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\CaracoleBundle\Repository\Section\SectionRepository; use Lc\CaracoleBundle\Repository\Section\SectionRepository;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Resolver\UrlResolver; use Lc\SovBundle\Resolver\UrlResolver;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Security; use Symfony\Component\Security\Core\Security;
protected $sectionRepository; protected $sectionRepository;
protected $merchantResolver; 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; $this->merchantResolver = $merchantResolver;
} }


$currentAdminSection = null; $currentAdminSection = null;
$userMerchant = $this->merchantResolver->getUserMerchant(); $userMerchant = $this->merchantResolver->getUserMerchant();


if($userMerchant!==null){
if ($userMerchant !== null) {
$currentAdminSection = $userMerchant->getCurrentAdminSection(); $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; return $currentAdminSection;
} }



Loading…
Cancel
Save