Você não pode selecionar mais de 25 tópicos
Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
|
- <?php
- /**
- * @author La clic ! <contact@laclic.fr>
- */
-
- namespace Lc\CaracoleBundle\Resolver;
-
- use Doctrine\ORM\EntityManagerInterface;
- use Lc\CaracoleBundle\Model\Section\SectionInterface;
- use Lc\CaracoleBundle\Repository\Section\SectionRepository;
- use Lc\SovBundle\Resolver\UrlResolver;
- use Symfony\Component\HttpFoundation\RequestStack;
- use Symfony\Component\Security\Core\Security;
-
- class SectionResolver
- {
- protected $sectionRepository;
- protected $merchantResolver;
-
- public function __construct(MerchantResolver $merchantResolver, EntityManagerInterface $em)
- {
- $this->em = $em;
- $this->merchantResolver = $merchantResolver;
- }
-
- public function getCurrent(): SectionInterface
- {
- $currentAdminSection = null;
- $userMerchant = $this->merchantResolver->getUserMerchant();
-
- if ($userMerchant !== null) {
- $currentAdminSection = $userMerchant->getCurrentAdminSection();
- }
-
- if ($currentAdminSection === null) {
- $currentAdminSection = $this->em->getRepository(SectionInterface::class)->findOneBy(array('isDefault' => true));
- if ($currentAdminSection === null) {
- throw new \ErrorException('Aucune section par défaut définie pour ce merchant');
- }
- }
- return $currentAdminSection;
- }
-
-
- }
|