src/Twig/OSExtension.php line 89
<?phpnamespace App\Twig;use Symfony\Component\Routing\RouterInterface;use Symfony\Component\HttpFoundation\RequestStack;use Twig\Extension\AbstractExtension;use Twig\TwigFilter;use Twig\TwigFunction;use OlaSoft\Common;class OSExtension extends AbstractExtension {private $common;private $router;public function __construct(RouterInterface $router){$this->common = new Common;$this->router = $router;}public function getFilters(){return [new TwigFilter('imagecolor', [$this->common, 'imagecolor']),new TwigFilter('imagesize', [$this->common, 'imagesize']),new TwigFilter('filesize', [$this->common, 'filesize']),new TwigFilter('pretty_size', [$this->common, 'prettySize']),new TwigFilter('pretty_date', [$this->common, 'prettyDate']),new TwigFilter('pretty_datetime', [$this->common, 'prettyDateTime']),new TwigFilter('slug', [$this->common, 'slug']),new TwigFilter('frdate', [$this->common, 'FrDate']),new TwigFilter('frdatetime', [$this->common, 'FrDateTime']),new TwigFilter('frmonth', [$this->common, 'FrMonth']),new TwigFilter('strftime', [$this->common, 'Strftime']),new TwigFilter('mobile', [$this->common, 'mobile']),new TwigFilter('desktop', [$this->common, 'desktop']),new TwigFilter('country', [$this->common, 'country']),new TwigFilter('youtubeId', [$this->common, 'getYoutubeId']),new TwigFilter('youtubeEmbed', [$this->common, 'getYoutubeEmbed']),new TwigFilter('youtubeThumbnail', [$this->common, 'getYoutubeThumbnail']),new TwigFilter('vimeoThumbnail', [$this->common, 'getVimeoThumbnail']),new TwigFilter('filterArray', [$this->common, 'filterArray']),new TwigFilter('summary', [$this->common, 'summary']),new TwigFilter('search', [$this, 'arraySearch']),new TwigFilter('values', [$this, 'arrayValues']),new TwigFilter('price', [$this->common, 'formatPrice']),new TwigFilter('amount', [$this->common, 'formatPrice']),new TwigFilter('isRoute', [$this, 'isRoute']),new TwigFilter('os_trans', [$this->common, 'translate']),new TwigFilter('os_trans_text', [$this->common, 'translateText']),new TwigFilter('checkdealine', [$this->common, 'CheckDealineFilter']),];}public function getFunctions(){return [new TwigFunction('isMobile', [$this->common, 'isMobile']),new TwigFunction('isDesktop', [$this->common, 'isDesktop']),new TwigFunction('mobile', [$this->common, 'mobile']),new TwigFunction('desktop', [$this->common, 'desktop']),new TwigFunction('downloadPDF', [$this->common, 'downloadPDF']),new TwigFunction('youtubeId', [$this->common, 'getYoutubeId']),new TwigFunction('youtubeEmbed', [$this->common, 'getYoutubeEmbed']),new TwigFunction('youtubeThumbnail', [$this->common, 'getYoutubeThumbnail']),new TwigFunction('vimeoThumbnail', [$this->common, 'getVimeoThumbnail']),new TwigFunction('filterArray', [$this->common, 'filterArray']),new TwigFunction('summary', [$this->common, 'summary']),new TwigFunction('os_param', [$this->common, 'getParameter']),new TwigFunction('price', [$this->common, 'formatPrice']),new TwigFunction('amount', [$this->common, 'formatPrice']),new TwigFunction('isRoute', [$this, 'isRoute']),new TwigFunction('localeIsFr', [$this->common, 'localeIsFr']),new TwigFunction('localeIsEn', [$this->common, 'localeIsEn']),new TwigFunction('locale', [$this->common, 'getLocale']),new TwigFunction('os_trans', [$this->common, 'translate']),new TwigFunction('os_trans_text', [$this->common, 'translateText']),new TwigFunction('checkdealine', [$this->common, 'CheckDealineFilter']),];}public function arraySearch($v, $t){return array_search($v,$t);}public function arrayValues($t){return array_values($t);}function isRoute($name){$router = $this->router;return (null === $router->getRouteCollection()->get($name)) ? false : true;}public function getName(){return 'os_extension';}}