Deprecated : Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 58
Deprecated : Constant E_STRICT is deprecated in /home/pastorz/old-espace-client/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler
<?php
namespace App\Service ;
use App\Entity\Brand ;
use Doctrine\ORM\EntityManagerInterface ;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface ;
class BrandService
{
private ?Brand $brand ;
public const CODE_ADN = 'adn' ;
public const CODE_NPCJ = 'npcj' ;
public const CODE_PMDV = 'pmdv' ;
/**
* @param ParameterBagInterface $parameterBag
* @param EntityManagerInterface $em
*/
public function __construct ( ParameterBagInterface $parameterBag , private EntityManagerInterface $em )
{
$this -> brand = $em -> getRepository ( Brand ::class)-> findOneByCode ( $parameterBag -> get ( 'brand' ));
}
/**
* @return Brand|null
*/
public function getBrand (): ? Brand
{
return $this -> brand ;
}
public function findBrand ( string $code ): ? Brand
{
return $this -> em -> getRepository ( Brand ::class)-> findOneByCode ( $code );
}
/**
* @return bool
*/
public function isADN (): bool
{
return $this -> brand -> getCode () == self :: CODE_ADN ;
}
/**
* @return bool
*/
public function isPMDV (): bool
{
return $this -> brand -> getCode () == self :: CODE_PMDV ;
}
/**
* @return bool
*/
public function isNPCJ (): bool
{
return $this -> brand -> getCode () == self :: CODE_NPCJ ;
}
}