Skip to content

Commit

Permalink
Add special HTTP view renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
drmad committed Jan 2, 2023
1 parent e7b3b2e commit ff50b2f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Vendimia\Exception\ResourceNotFoundException;
use Vendimia\Http\Response;

use const Vendimia\DEBUG;

/**
* Simple PHP view rendering engine
*/
Expand Down Expand Up @@ -158,4 +160,20 @@ public function renderResponse(): Response

return $response;
}

/**
* Renders a HTTP status code special view.
*/
public function renderHttpStatus($code, $args): noreturn
{
$source = '::http-status/' . $code;

if (DEBUG) {
$source .= '-debug';
}
$this->setSource($source);
$this->addArguments($args);
$this->renderResponse()->withStatus($code)->send();
exit;
}
}

0 comments on commit ff50b2f

Please sign in to comment.