Example #1
0
 /**
  * A template to add to the view and return.
  *
  * @param string $template The template name to load into the view.
  */
 public function template($template, $data = array())
 {
     \Template::with($template, $data);
     \View::serve();
 }
Example #2
0
 public function getEdit()
 {
     \View::title('Edit Your Account Information');
     \Template::with('user/edit');
 }
Example #3
0
 public function getPasswordReset($token)
 {
     if (!\Session::hasFlash('pw-reset-success') && !\App::with('User')->isValidToken($token, 'password')) {
         return false;
     }
     //if
     \View::title('Reset Your Password');
     \Template::with('user/password-reset');
 }
Example #4
0
 /**
  * Logic for `/` route.
  */
 public function getIndex()
 {
     \View::title('Your Site Home Page');
     \Template::with('index.html');
 }
Example #5
0
 /**
  * Serve a specified http response code page by either executing a template or the passed \Closure $fun function, 
  * or loading the \Closure function from the file $this->errorDir . $code.php and executing it or by 
  * a default message set by the function.
  *
  *
  * @param int $code The http repsonse code sent to the client from the server.
  * @param boolean|string|\Closure $action A template or closure to execute when $code != 200.
  * @return void 
  */
 public final function serve($code = 200, $action = false)
 {
     if ($code != 200) {
         //set the response code
         http_response_code($code);
         //clear the body of the view
         \View::body('');
         if (is_string($action)) {
             \Template::with($action);
         } else {
             if ($action !== false && $action instanceof \Closure) {
                 call_user_func($action);
             } else {
                 $file = \App::path() . '/' . trim($this->errorDir, '/') . '/' . $code . '.php';
                 if (is_file($file)) {
                     $action = (require $file);
                     call_user_func($action, \App::instance());
                 }
                 //if
             }
         }
         //el
     }
     //if
     //Print out the Current View.
     if (!\App::instance()->cli) {
         \View::printPage();
     }
     //if
     exit;
 }