|
|
|
|
|
|
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
|
|
use Symfony\Component\Form\FormFactoryInterface; |
|
|
use Symfony\Component\Form\FormFactoryInterface; |
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
|
|
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
|
|
use Symfony\Component\Security\Core\Security; |
|
|
use Symfony\Component\Security\Core\Security; |
|
|
use Twig\Extension\AbstractExtension; |
|
|
use Twig\Extension\AbstractExtension; |
|
|
use Twig\TwigFilter; |
|
|
use Twig\TwigFilter; |
|
|
|
|
|
|
|
|
protected $productFamilyRepository; |
|
|
protected $productFamilyRepository; |
|
|
protected $liipCacheHelper; |
|
|
protected $liipCacheHelper; |
|
|
protected $parameterBag; |
|
|
protected $parameterBag; |
|
|
|
|
|
protected $kernel; |
|
|
|
|
|
|
|
|
public function __construct(EntityManagerInterface $em, Security $security, MerchantUtilsInterface $merchantUtils, |
|
|
public function __construct(EntityManagerInterface $em, Security $security, MerchantUtilsInterface $merchantUtils, |
|
|
FormFactoryInterface $formFactory, RequestStack $requestStack, CacheManager $liipCacheHelper, |
|
|
FormFactoryInterface $formFactory, RequestStack $requestStack, CacheManager $liipCacheHelper, |
|
|
ParameterBagInterface $parameterBag) |
|
|
|
|
|
|
|
|
ParameterBagInterface $parameterBag, KernelInterface $kernel) |
|
|
{ |
|
|
{ |
|
|
$this->em = $em; |
|
|
$this->em = $em; |
|
|
$this->security = $security; |
|
|
$this->security = $security; |
|
|
|
|
|
|
|
|
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetadata(ProductFamilyInterface::class)->getName()); |
|
|
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetadata(ProductFamilyInterface::class)->getName()); |
|
|
$this->liipCacheHelper = $liipCacheHelper; |
|
|
$this->liipCacheHelper = $liipCacheHelper; |
|
|
$this->parameterBag = $parameterBag; |
|
|
$this->parameterBag = $parameterBag; |
|
|
|
|
|
$this->kernel = $kernel; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getFunctions() |
|
|
public function getFunctions() |
|
|
|
|
|
|
|
|
return [ |
|
|
return [ |
|
|
new TwigFilter('format_price', [$this, 'formatPrice']), |
|
|
new TwigFilter('format_price', [$this, 'formatPrice']), |
|
|
new TwigFilter('lc_liip', [$this, 'lcLiip']), |
|
|
new TwigFilter('lc_liip', [$this, 'lcLiip']), |
|
|
|
|
|
new TwigFilter('lc_cache', [$this, 'lcCache']), |
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function lcCache($file){ |
|
|
|
|
|
$cacheTime = filemtime($this->kernel->getProjectDir().'/public'.$file); |
|
|
|
|
|
if($cacheTime){ |
|
|
|
|
|
return $file.'?c='.$cacheTime; |
|
|
|
|
|
}else{ |
|
|
|
|
|
return $file."?c=0"; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function lcLiip($path, $thumb = 'tile', $default = 'default.jpg') |
|
|
public function lcLiip($path, $thumb = 'tile', $default = 'default.jpg') |
|
|
{ |
|
|
{ |
|
|
if (substr($path, 0, 1) === '/') $path = substr($path, 1); |
|
|
if (substr($path, 0, 1) === '/') $path = substr($path, 1); |