addExtension(new \Twig_Extension_Debug()); /** * ADD TWIG EXTENDS FROM FOLDER */ try { $functionsDir = __DIR__ . DIRECTORY_SEPARATOR . '_functions'; $filtersDir = __DIR__ . DIRECTORY_SEPARATOR . '_filters'; if ($handle = opendir($functionsDir)) { while (false !== ($fileName = readdir($handle))) { if ($fileName[0] != "_" && $fileName[0] != "." && substr_count( $fileName, '.function.php' )) { include($functionsDir . DIRECTORY_SEPARATOR . $fileName); // $function should be defined in the included file if (isset($function)) { $env->addFunction($function); unset($function); } } } } if ($handle = opendir($filtersDir)) { while (false !== ($fileName = readdir($handle))) { if ($fileName[0] != "_" && $fileName[0] != "." && substr_count($fileName, '.filter.php')) { include($filtersDir . DIRECTORY_SEPARATOR . $fileName); // $filter should be defined in the included file if (isset($filter)) { $env->addFilter($filter); unset($filter); } } } } // echo '--- ADDED TWIG EXT IN ' . (microtime(true) - $time) . 'ms' . PHP_EOL; } catch (Exception $e) { echo $e . PHP_EOL; } }