|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FrontendTwigExtension extends AbstractExtension |
|
|
class FrontendTwigExtension extends AbstractExtension |
|
|
{ |
|
|
{ |
|
|
protected $em ; |
|
|
|
|
|
protected $security ; |
|
|
|
|
|
protected $merchantUtils ; |
|
|
|
|
|
protected $formFactory ; |
|
|
|
|
|
protected $requestStack ; |
|
|
|
|
|
protected $productCategoryRepository ; |
|
|
|
|
|
protected $merchantRepository ; |
|
|
|
|
|
protected $productFamilyRepository ; |
|
|
|
|
|
protected $liipCacheHelper ; |
|
|
|
|
|
protected $parameterBag ; |
|
|
|
|
|
|
|
|
protected $em; |
|
|
|
|
|
protected $security; |
|
|
|
|
|
protected $merchantUtils; |
|
|
|
|
|
protected $formFactory; |
|
|
|
|
|
protected $requestStack; |
|
|
|
|
|
protected $productCategoryRepository; |
|
|
|
|
|
protected $merchantRepository; |
|
|
|
|
|
protected $productFamilyRepository; |
|
|
|
|
|
protected $liipCacheHelper; |
|
|
|
|
|
protected $parameterBag; |
|
|
|
|
|
|
|
|
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) |
|
|
{ |
|
|
{ |
|
|
$this->em = $em ; |
|
|
|
|
|
$this->security = $security ; |
|
|
|
|
|
$this->merchantUtils = $merchantUtils ; |
|
|
|
|
|
$this->formFactory = $formFactory ; |
|
|
|
|
|
$this->requestStack = $requestStack ; |
|
|
|
|
|
$this->productCategoryRepository = $this->em->getRepository($this->em->getClassMetadata(ProductCategoryInterface::class)->getName()) ; |
|
|
|
|
|
$this->merchantRepository = $this->em->getRepository($this->em->getClassMetadata(MerchantInterface::class)->getName()) ; |
|
|
|
|
|
$this->productFamilyRepository = $this->em->getRepository($this->em->getClassMetadata(ProductFamilyInterface::class)->getName()) ; |
|
|
|
|
|
|
|
|
$this->em = $em; |
|
|
|
|
|
$this->security = $security; |
|
|
|
|
|
$this->merchantUtils = $merchantUtils; |
|
|
|
|
|
$this->formFactory = $formFactory; |
|
|
|
|
|
$this->requestStack = $requestStack; |
|
|
|
|
|
$this->productCategoryRepository = $this->em->getRepository($this->em->getClassMetadata(ProductCategoryInterface::class)->getName()); |
|
|
|
|
|
$this->merchantRepository = $this->em->getRepository($this->em->getClassMetadata(MerchantInterface::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; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function lcLiip($path, $thumb = 'tile', $default = 'default.jpg') |
|
|
public function lcLiip($path, $thumb = 'tile', $default = 'default.jpg') |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
if(strpos($path, $this->getFileManagerFolder())===false){ |
|
|
|
|
|
$path = $this->getFileManagerFolder() .'/'. $path; |
|
|
|
|
|
|
|
|
if (substr($path, 0, 1) === '/') $path = substr($path, 1); |
|
|
|
|
|
|
|
|
|
|
|
if (strpos($path, $this->getFileManagerFolder()) === false) { |
|
|
|
|
|
$path = $this->getFileManagerFolder() . '/' . $path; |
|
|
} |
|
|
} |
|
|
|
|
|
dump($path); |
|
|
|
|
|
|
|
|
if ($path) { |
|
|
if ($path) { |
|
|
|
|
|
|
|
|
return $this->liipCacheHelper->getBrowserPath($path, $thumb); |
|
|
return $this->liipCacheHelper->getBrowserPath($path, $thumb); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
|
|
|
return $this->liipCacheHelper->getBrowserPath('assets/img/frontend/'.$default, $thumb); |
|
|
|
|
|
|
|
|
return $this->liipCacheHelper->getBrowserPath('assets/img/frontend/' . $default, $thumb); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* |
|
|
* |
|
|
* @return string |
|
|
* @return string |
|
|
*/ |
|
|
*/ |
|
|
public function getFileManagerFolder(){ |
|
|
|
|
|
|
|
|
public function getFileManagerFolder() |
|
|
|
|
|
{ |
|
|
return $this->parameterBag->get('app.path.images'); |
|
|
return $this->parameterBag->get('app.path.images'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getProductCategories() |
|
|
public function getProductCategories() |
|
|
{ |
|
|
{ |
|
|
$categories = $this->productCategoryRepository->findAllParents($this->merchantUtils->getMerchantCurrent()) ; |
|
|
|
|
|
return $categories ; |
|
|
|
|
|
|
|
|
$categories = $this->productCategoryRepository->findAllParents($this->merchantUtils->getMerchantCurrent()); |
|
|
|
|
|
return $categories; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getFormNewsletter() |
|
|
public function getFormNewsletter() |
|
|
{ |
|
|
{ |
|
|
$form = $this->formFactory->create(NewsletterType::class); |
|
|
$form = $this->formFactory->create(NewsletterType::class); |
|
|
return $form->createView() ; |
|
|
|
|
|
|
|
|
return $form->createView(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function formatPrice($price) |
|
|
public function formatPrice($price) |
|
|
{ |
|
|
{ |
|
|
$price = number_format($price, 2, ',', ' ') ; |
|
|
|
|
|
$price = $price .' €' ; |
|
|
|
|
|
return $price ; |
|
|
|
|
|
|
|
|
$price = number_format($price, 2, ',', ' '); |
|
|
|
|
|
$price = $price . ' €'; |
|
|
|
|
|
return $price; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getMerchants() |
|
|
public function getMerchants() |
|
|
{ |
|
|
{ |
|
|
return $this->merchantRepository->findAll() ; |
|
|
|
|
|
|
|
|
return $this->merchantRepository->findAll(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |