/** * Hidden from user. Runs only once. * Initializes application context. * @internal */ private function __construct() { $this->config = new TipyConfig(); $this->request = new TipyRequest(); $this->env = new TipyEnv(); $this->cookie = new TipyCookie(); $this->in = new TipyInput(); $this->out = new TipyOutput(); $this->view = new TipyView(); $this->db = null; // Lazy database connection if (CLI_MODE) { $this->session = new TipyCliSession(); } else { $this->session = new TipySession(); } // dispatcher.php is called by Apache with current working dir set to DocumentRoot $cwd = getcwd(); $this->documentRoot = $cwd; $this->view->setTemplatePath(realpath($cwd . '/../app/views')); $this->setupLogger(); }
/** * Render template and return result as a string * @param string $templateName * @return string */ public function renderTemplate($templateName) { $this->view->bind($this->out->getAll()); return $this->view->processTemplate($templateName); }