src/Service/GlobalService.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. use Doctrine\Persistence\ManagerRegistry;
  4. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  5. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  6. class GlobalService
  7. {
  8.     protected $mr;
  9.     protected $session;
  10.     protected $params;
  11.     protected $headquarterWarehouses;
  12.     protected $company;
  13.     public function __construct(ManagerRegistry $mrSessionInterface $sessionParameterBagInterface $params)
  14.     {
  15.         $this->mr $mr;
  16.         $this->session $session;
  17.         $this->params $params;
  18.     }
  19.     public function getHeadquarterWarehouses(){
  20.         if($this->session->get("companyId") != null){
  21.             $emMaster $this->mr->getManager('master');
  22.             $company $emMaster->getRepository('App\Entity\Master\Company')->findOneById($this->session->get("companyId"));
  23.             $em CompanyService::getSlaveManagerByCompany($this->mr$this->params$company);
  24.             $headquarterWarehouses $em->getRepository("App\Entity\Slave\Warehouse")->findHeadquarterWarehouses();
  25.             $this->headquarterWarehouses $headquarterWarehouses;
  26.             return $this->headquarterWarehouses;
  27.         }
  28.         return null;
  29.     }
  30.     
  31.     public function getActualCompany(){
  32.         if($this->session->get("companyId") != null){
  33.             $emMaster $this->mr->getManager('master');
  34.             $company $emMaster->getRepository('App\Entity\Master\Company')->findOneById($this->session->get("companyId"));
  35.             $this->company $company;
  36.             return $this->company;
  37.         }
  38.         return null;
  39.     }
  40. }