public static function singleton() { if (!isset(self::$instance)) { self::$instance = new ViewDirectory(); } return self::$instance; }
function view($view_function_name, $data, $options = array()) { $viewDirectory = ViewDirectory::singleton(); $path = $viewDirectory->find($view_function_name); if (!$path) { bail("<b>{$view_function_name}</b> cannot be found. Please add it to the View Directory."); } if (!file_exists($path)) { bail("View file <b>{$path}</b> does not exist, or has not been added to the View Directory."); } require_once $path; $response = $view_function_name($data, $options); if (empty($options['get_tokens']) && is_array($response)) { return $response['body']; } return $response; }