コード例 #1
0
ファイル: php.php プロジェクト: sasanrose/nanophp
 /**
  * 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));
 }
コード例 #2
0
ファイル: Application.php プロジェクト: sasanrose/nanophp
 /**
  * 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;
 }
コード例 #3
0
ファイル: Error.php プロジェクト: sasanrose/nanophp
 /**
  * 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']);
 }