public static function connect() { if (self::$translation === null) { self::$translation = new Translation(['bundle' => null, 'theme' => 'sybil', 'domain' => 'debug']); } if (self::$db === null) { $model_path = CORE_SRC . 'ORM/' . Config::$dbms_to_use . '/Model.php'; if (file_exists($model_path)) { require_once $model_path; $class_name = '\\Sybil\\ORM\\' . Config::$dbms_to_use . '\\' . Config::$dbms_to_use; self::$db = $class_name::connect(); return self::$db; } else { if (ENVIRONMENT == 'production') { $this->redirect('unavailable'); } else { App::translate("dbms_file_missing", self::$translation); die; } } } }
public function render($view_name = 'index', $escape = true) { $view_path = BUNDLE . $this->route_data->bundle . '/view/' . $view_name . '.html.twig'; if (file_exists($view_path)) { $this->vars->extract(); // Directories where Twig will search for templates. $template_directories = [BUNDLE . $this->route_data->bundle . '/view', APP . 'theme/manager/view', APP . 'theme/' . Config::$theme . '/view']; $loader = new Twig_Loader_Filesystem($template_directories); if (ENVIRONMENT == 'production') { $twig = new Twig_Environment($loader, ['cache' => CACHE . 'view', 'debug' => false, 'autoescape' => $escape]); } else { $twig = new Twig_Environment($loader, ['cache' => false, 'debug' => true, 'autoescape' => $escape]); } TwigFunctions::initFunctions($twig); // Loading custom Twig functions if ($this->store === false) { echo $twig->render($view_name . '.html.twig', $this->vars->toArray()); } else { $this->template = $twig->render($view_name . '.html.twig', $this->vars->toArray()); } } else { if (ENVIRONMENT == 'production') { $this->setError(); } else { $this->translate->setVar('view_path', $view_path); $this->translate->setVar('bundle', $this->route_data->bundle); App::translate("missing_view_file", $this->translate, $this->trans_debug); die; } } }