Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
www.humitest.fr
/
htdocs
/
src
/
Twig
/
/srv/data/web/vhosts/www.humitest.fr/htdocs/src/Twig/AppExtension.php
<?php namespace App\Twig; use Twig\TwigFilter; use Twig\Extension\AbstractExtension; use App\Repository\ConfigurationRepository; class AppExtension extends AbstractExtension { public function getFilters() { return [ new TwigFilter('my_url_encode', [$this, 'myUrlEncode']), ]; } public function myUrlEncode($text) { // replace non letter or digits by - $text = preg_replace('~[^\pL\d]+~u', '-', $text); // transliterate doesn't work in server //$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); $transliteration = array( 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 'Ñ' => 'N', 'ñ' => 'n', 'Ç' => 'C', 'ç' => 'c' ); $text = strtr($text, $transliteration); // remove unwanted characters $text = preg_replace('~[^-\w]+~', '', $text); // trim $text = trim($text, '-'); // remove duplicate - $text = preg_replace('~-+~', '-', $text); // lowercase $text = strtolower($text); if (empty($text)) { return 'n-a'; } return $text; } public function convertEuro($value) { $value = floatval($value) * $this->rateEuro; return $value; } }