Esempio n. 1
0
 /**
  * Load view file
  *
  * @param  string $file Name of the view file
  * @param  array  $data Array of data to be bind on the view
  *
  * @throws \SilverWp\Exception
  * @return String The result view
  * @access public
  */
 public function load($file, $data = array(), $extension = 'php')
 {
     $view_file = $file . '.' . $extension;
     if (!file_exists($view_file)) {
         throw new Exception("View file not found: {$view_file}");
     }
     \extract($data);
     // fix bug when data is form Ajaxt request
     if (AjaxAbstract::isAjax()) {
         return include $view_file;
     } else {
         \ob_start();
         include $view_file;
         $content = \ob_get_clean();
         return $content;
     }
 }