Last active
September 15, 2021 23:32
-
-
Save bernard-ng/b1b61d56a5ffc875c5f20529f0d266d1 to your computer and use it in GitHub Desktop.
Revisions
-
bernard-ng revised this gist
Sep 15, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ class DisallowCountryRepository extends ServiceEntityRepository * DisallowCountryRepository constructor. * @param ManagerRegistry $registry * @param LoggerInterface $logger * @author bernard-ng <[email protected]> */ public function __construct(ManagerRegistry $registry, LoggerInterface $logger) { @@ -34,7 +34,7 @@ public function __construct(ManagerRegistry $registry, LoggerInterface $logger) /** * @return array * @author bernard-ng <[email protected]> */ public function getDisallowedCountries(): array { -
bernard-ng created this gist
Mar 1, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ <?php declare(strict_types=1); namespace App\Repository; use App\Entity\DisallowCountry; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; use Exception; use Psr\Log\LoggerInterface; /** * @method DisallowCountry|null find($id, $lockMode = null, $lockVersion = null) * @method DisallowCountry|null findOneBy(array $criteria, array $orderBy = null) * @method DisallowCountry[] findAll() * @method DisallowCountry[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ class DisallowCountryRepository extends ServiceEntityRepository { private LoggerInterface $logger; /** * DisallowCountryRepository constructor. * @param ManagerRegistry $registry * @param LoggerInterface $logger * @author bernard-ng <[email protected]> */ public function __construct(ManagerRegistry $registry, LoggerInterface $logger) { parent::__construct($registry, DisallowCountry::class); $this->logger = $logger; } /** * @return array * @author bernard-ng <[email protected]> */ public function getDisallowedCountries(): array { $sql = <<< SQL SELECT iso2 FROM disallow_country WHERE has_access = '0' ORDER BY name SQL; try { $connexion = $this->_em->getConnection(); $statement = $connexion->prepare($sql); $statement->execute(); // important nous avons d'un tableau contenant unique la list de pays // ['CD', 'CA', 'FR', 'US'] par exemple return $statement->fetchFirstColumn(); } catch (Exception | \Doctrine\DBAL\Driver\Exception $e) { $this->logger->error($e->getMessage(), $e->getTrace()); return []; } } }