kernel = $kernel; $this->parameterBag = $parameterBag; $this->cacheManager = $cacheManager; $this->em = $entityManager; $this->requestStack = $requestStack; $this->router = $router; $this->translator = $translator; $this->translatorAdmin = $translatorAdmin; $this->reminderStore = $reminderStore; $this->security = $security; } public function getFunctions() { return [ new TwigFunction('sov_liip', [$this, 'liip']), new TwigFunction('sov_get_by_devalias', [$this, 'getByDevAlias']), new TwigFunction('sov_parameter', [$this, 'getParameter']), new TwigFunction('sov_homepage_route', [$this, 'getHomepageRoute']), new TwigFunction('lc_format_price', [$this, 'formatPrice']), new TwigFunction('die', [$this, 'die']), ]; } public function die() { die(); } public function getFilters() { return [ new TwigFilter('uc_first', [$this, 'ucFirst']), new TwigFilter('format_price', [$this, 'formatPrice']), ]; } public function formatPrice($price, $unbreakableSpace = true) { $price = number_format($price, 2, ',', ' '); $price .= $unbreakableSpace ? ' ' : ' '; $price .= '€'; return $price; } public function ucFirst($string) { return ucfirst($string); } public function liip($path, $thumb = 'tile', $default = 'default.jpg') { if (substr($path, 0, 1) === '/') { $path = substr($path, 1); } if ($path) { $fileManagerFolder = substr($this->getFileManagerFolder(), 1); if (strpos($path, $fileManagerFolder) === false) { $path = $fileManagerFolder.'/'.$path; } if (file_exists($path)) { return $this->cacheManager->getBrowserPath($path, $thumb); } } return $this->cacheManager->getBrowserPath($this->getFileManagerFolder().'/'.$default, $thumb); } public function getFileManagerFolder() { return $this->parameterBag->get('app.path_uploads'); } public function getHomepageRoute() { return $this->parameterBag->get('lc_sov.homepage_route'); } public function getParameter($name) { return $this->parameterBag->get($name); } }