/** * Constructor - Called on each request. */ public static function construct($class = null, $method = null) { // Get full urls to current controller and its method $site_url = Router::siteUrl(); self::$method_url = $site_url . Router::$method_url . '/'; self::$controller_url = dirname(self::$method_url) . '/'; self::$module_url = dirname(self::$controller_url) . '/'; // Pass these to the view, too Load::$config['view_data']['module_url'] = self::$module_url; Load::$config['view_data']['controller_url'] = self::$controller_url; Load::$config['view_data']['method_url'] = self::$method_url; // Add Router's preferences Load::$config['view_data']['module'] = Router::$module; Load::$config['view_data']['controller'] = Router::$controller; Load::$config['view_data']['class'] = Router::$class; Load::$config['view_data']['method'] = Router::$method; }
if (empty(Load::$config['disable_twig'])) { if (is_file(BASE_PATH . 'Vendor/twig/twig/lib/Twig/Token.php') !== true) { throw new Exception('Twig Not Found! If you installed StaticPHP manually, not using composer, please see README.md to where to place the twig library.'); } require BASE_PATH . 'Vendor/autoload.php'; Load::$config['view_loader'] = new Twig_Loader_Filesystem([APP_MODULES_PATH, SYS_MODULES_PATH . 'Core/Views']); Load::$config['view_engine'] = new Twig_Environment(Load::$config['view_loader'], array('cache' => APP_PATH . 'Cache/Views/', 'debug' => Load::$config['debug'])); // Register default filters and functions // Site url filter $filter = new Twig_SimpleFilter('siteUrl', function ($url = null, $prefix = null, $current_prefix = true) { return Router::siteUrl($url, $prefix, $current_prefix); }); Load::$config['view_engine']->addFilter($filter); // Site url function $function = new Twig_SimpleFunction('siteUrl', function ($url = null, $prefix = null, $current_prefix = true) { return Router::siteUrl($url, $prefix, $current_prefix); }); Load::$config['view_engine']->addFunction($function); // Start timer function $function = new Twig_SimpleFunction('startTimer', function () { Load::startTimer(); }); Load::$config['view_engine']->addFunction($function); // Stop timer function $function = new Twig_SimpleFunction('stopTimer', function ($name) { Load::stopTimer($name); }); Load::$config['view_engine']->addFunction($function); // Mark time function $function = new Twig_SimpleFunction('markTime', function ($name) { Load::markTime($name);