You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- <?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;
- }
-
-
- }
|