소스 검색

Correctig SectionResolver

feature/ticket
Guillaume 3 년 전
부모
커밋
6db253f307
2개의 변경된 파일10개의 추가작업 그리고 6개의 파일을 삭제
  1. +1
    -1
      Repository/Section/SectionRepository.php
  2. +9
    -5
      Resolver/SectionResolver.php

+ 1
- 1
Repository/Section/SectionRepository.php 파일 보기

@@ -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 파일 보기

@@ -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;
}


Loading…
취소
저장