src/Service/ServiceRetriever.php line 185

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. use App\Form\DataTransformer\DataTransformerRetriever;
  4. use App\Library\EnvManager;
  5. use App\Service\CashbackTransaction\CashbackTransactionService;
  6. use App\Service\Client\ClientService;
  7. use Doctrine\ORM\EntityManagerInterface;
  8. use Symfony\Component\DependencyInjection\ContainerInterface;
  9. use Symfony\Component\Form\FormFactory;
  10. use Symfony\Component\Security\Core\Security;
  11. class ServiceRetriever
  12. {
  13.     private $services = [];
  14.     /**
  15.      * @var self
  16.      */
  17.     private static $INSTANCE;
  18.     /**
  19.      * @var ContainerInterface
  20.      */
  21.     private $container;
  22.     /**
  23.      * @var ClientService
  24.      */
  25.     private $clientService;
  26.     /**
  27.      * @var InkassService
  28.      */
  29.     private $inkassService;
  30.     /**
  31.      * @var MachineService
  32.      */
  33.     private $machineService;
  34.     /**
  35.      * @var CompanyService
  36.      */
  37.     private $companyService;
  38.     /**
  39.      * @var SessionService
  40.      */
  41.     private $sessionService;
  42.     /**
  43.      * @var RouteService
  44.      */
  45.     private $routeService;
  46.     /**
  47.      * @var EnvManager
  48.      */
  49.     private $envManager;
  50.     /**
  51.      * @var EntityManagerInterface
  52.      */
  53.     private $em;
  54.     /**
  55.      * @var PromoCodeService
  56.      */
  57.     private $promoCodeService;
  58.     /**
  59.      * @var CarWashService
  60.      */
  61.     private $carWashService;
  62.     /**
  63.      * @var KktService
  64.      */
  65.     private $kktService;
  66.     /**
  67.      * @var \Symfony\Component\Security\Core\Security
  68.      */
  69.     private $security;
  70.     /**
  71.      * @var ClientNotificationService
  72.      */
  73.     private $clientNotificationService;
  74.     /**
  75.      * @var ClientNotificationReplyService
  76.      */
  77.     private $clientNotificationReplyService;
  78.     /**
  79.      * @var AccessTokenService
  80.      */
  81.     private $accessTokenService;
  82.     /**
  83.      * @var CityService
  84.      */
  85.     private $cityService;
  86.     /**
  87.      * @var DataTransformerRetriever
  88.      */
  89.     private $dataTransformerRetriever;
  90.     /**
  91.      * @var AuthorizationService
  92.      */
  93.     private $authorizationService;
  94.     /**
  95.      * @var StoryService
  96.      */
  97.     private $storyService;
  98.     /**
  99.      * @var ClientTransactionService
  100.      */
  101.     private $clientTransactionService;
  102.     /**
  103.      * @var CashbackTransactionService
  104.      */
  105.     private $cashbackTransactionService;
  106.     /**
  107.      * @var EntityViewService
  108.      */
  109.     private $entityViewService;
  110.     /**
  111.      * @var FrontEndPreprocessorRetriever
  112.      */
  113.     private $frontEndPreprocessorRetriever;
  114.     /**
  115.      * @var InvoiceSevice
  116.      */
  117.     private $invoiceService;
  118.     public function __construct(ContainerInterface $containerSecurity $security)
  119.     {
  120.         $this->container $container;
  121.         $this->security $security;
  122.     }
  123.     public static function setInstance(self $instance): void
  124.     {
  125.         self::$INSTANCE $instance;
  126.     }
  127.     public static function getInstance(): self
  128.     {
  129.         return self::$INSTANCE;
  130.     }
  131.     public function getCityService(): CityService
  132.     {
  133.         if (!$this->cityService) {
  134.             $this->cityService $this->container->get(CityService::class);
  135.         }
  136.         return $this->cityService;
  137.     }
  138.     public function getRouteService(): RouteService
  139.     {
  140.         if (!$this->routeService) {
  141.             $this->routeService $this->container->get(RouteService::class);
  142.         }
  143.         return $this->routeService;
  144.     }
  145.     public function getDataTransformerRetriever(): DataTransformerRetriever
  146.     {
  147.         if (!$this->dataTransformerRetriever) {
  148.             $this->dataTransformerRetriever $this->container->get(DataTransformerRetriever::class);
  149.         }
  150.         return $this->dataTransformerRetriever;
  151.     }
  152.     public function getEm(): EntityManagerInterface
  153.     {
  154.         if (!$this->em) {
  155.             $this->em $this->container->get("doctrine.orm.entity_manager");
  156.         }
  157.         return $this->em;
  158.     }
  159.     public function getSecurity(): \Symfony\Component\Security\Core\Security
  160.     {
  161.         return $this->security;
  162.     }
  163.     public function getService(string $class)
  164.     {
  165.         if (isset($this->services[$class])) {
  166.             return $this->services[$class];
  167.         }
  168.         $this->services[$class] = $this->container->get($class);
  169.         return $this->services[$class];
  170.     }
  171.     public function getFormFactory(): FormFactory
  172.     {
  173.         return $this->container->get('form.factory');
  174.     }
  175. }