src/Service/ServiceRetriever.php line 189

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