Beispiel #1
0
 /**
  * render
  *
  * Render method in templates does the job and displays the content
  * @param string $__view The name of view file to find
  * @param array $data
  */
 public function render($__view, $data = array())
 {
     // Render the requested view
     $content = $this->renderPartial($__view, $data);
     // Output the rendered view via a default layout
     echo $this->renderPartial(Config::instance()->get('/default_layout', 'layouts/default'), array('content' => $content));
 }
Beispiel #2
0
 /**
  * logger
  *
  * Get instance of logger
  */
 public static function logger()
 {
     if (!isset(self::$_logger)) {
         self::$_logger = new Logger('NanoPHP');
         self::$_logger->pushHandler(\nanophp\Libraries\Config::instance()->get('log/handler'));
     }
     return self::$_logger;
 }
Beispiel #3
0
 /**
  * init
  *
  * Register error handling functions and set display errors
  */
 public function init()
 {
     // Check if we should display errors
     if (Config::instance()->get('production')) {
         ini_set('display_errors', 0);
         ini_set('display_startup_errors', 0);
     }
     // Set error reporting if there is a reporting level set in config file
     if (($error_reporting = Config::instance()->get('error/reporting', false)) !== False) {
         error_reporting($error_reporting);
     }
     // Set a custom error handler
     set_error_handler([$this, 'errorHandler']);
     // Set a custom exception handler
     set_exception_handler([$this, 'exceptionHanler']);
     // Set a custom shutdown handler
     register_shutdown_function([$this, 'shutdownHandler']);
 }