function __construct($di)
 {
     global $lgs_application_dir, $opcache_installed, $nocache;
     $this->di = $di;
     $controllerNamespace = '';
     if (!empty($di->routing['module'])) {
         $controllerNamespace .= '\\Modules\\' . ucfirst(strtolower($di->routing['module']));
         if (!empty($di->routing['submodule'])) {
             $controllerNamespace .= '\\Submodules\\' . ucfirst(strtolower($di->routing['submodule']));
         }
         $this->viewPath = $lgs_application_dir . 'app' . $controllerNamespace . '/views/';
     } else {
         $this->viewPath = $lgs_application_dir . 'app/views/';
     }
     $controllerNamespace .= '\\Controllers';
     $controllerNamespaceName = ucfirst(strtolower($di->routing['controller']));
     $controllerNamespace .= '\\' . $controllerNamespaceName;
     $controllerNamespaceClassName = $controllerNamespace . 'Controller';
     if ($opcache_installed) {
         $layoutId = 1;
         // depends on a file main layout/template now done in a dummy way
         $macrosPath = __DIR__ . '/../app//views/partials/macros/global_scope_profiles/profile-' . $layoutId . '.php';
         if ($nocache) {
             require_once __DIR__ . '/../app//views/partials/macros/global_scope_profiles/profile-' . $layoutId . '.php';
         }
         if (!opcache_is_script_cached($macrosPath)) {
             opcache_compile_file($macrosPath);
         }
     }
     if (!isset($di->view)) {
         $di->view = new View($di);
     }
     if (!isset($di->flow)) {
         $di->flow = new Flow($di);
     }
     if (!isset($di->db)) {
         $di->db = new Db($di);
     }
     Model::$staticdi = $di;
     Model::$staticdb = $di->db;
     $controller = new $controllerNamespaceClassName($di);
     $actionFunctionName = $di->routing['action'] . 'Action';
     $this->templateRelativePath = $controllerNamespaceName . '/' . $di->routing['action'] . '.php';
     $controller->{$actionFunctionName}();
     $templatePath = $this->viewPath . $this->templateRelativePath;
     if (file_exists($templatePath)) {
         include str_replace('\\', '/', $templatePath);
     }
 }