Version 5.1 - All the GraphQL #32
@ -99,7 +99,6 @@ return [
|
||||
'login' => [
|
||||
'path' => '/{controller}/login',
|
||||
'action' => 'login',
|
||||
'verb' => 'get'
|
||||
],
|
||||
'login_post' => [
|
||||
'path' => '/{controller}/login',
|
||||
@ -113,6 +112,7 @@ return [
|
||||
'update' => [
|
||||
'path' => '/{controller}/update',
|
||||
'action' => 'update',
|
||||
'verb' => 'post',
|
||||
'tokens' => [
|
||||
'controller' => '[a-z_]+'
|
||||
]
|
||||
|
@ -1,5 +1,5 @@
|
||||
<main>
|
||||
<h1><?= $title ?></h1>
|
||||
<h2><?= $message ?></h2>
|
||||
<div><?= $log_message ?></div>
|
||||
</main>
|
||||
<div><?= $long_message ?></div>
|
||||
</main>
|
@ -1,6 +1,6 @@
|
||||
sonar.projectKey=animeclient
|
||||
sonar.projectName=Anime Client
|
||||
sonar.projectVersion=2.0.0
|
||||
sonar.projectVersion=2.1.0
|
||||
sonar.sources=src
|
||||
sonar.php.coverage.reportPath=build/logs/clover.xml
|
||||
sonar.php.tests.reportPath=build/logs/junit.xml
|
@ -306,24 +306,25 @@ class Controller {
|
||||
{
|
||||
$this->outputHTML('404', [
|
||||
'title' => 'Sorry, page not found'
|
||||
]);
|
||||
], NULL, 404);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a generic error page
|
||||
*
|
||||
* @param int $http_code
|
||||
* @param string $title
|
||||
* @param string $message
|
||||
* @param string $long_message
|
||||
* @return void
|
||||
*/
|
||||
public function error_page($title, $message, $long_message = "")
|
||||
public function error_page($http_code, $title, $message, $long_message = "")
|
||||
{
|
||||
$this->outputHTML('error', [
|
||||
'title' => $title,
|
||||
'message' => $message,
|
||||
'long_message' => $long_message
|
||||
]);
|
||||
], NULL, $http_code);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -365,15 +366,17 @@ class Controller {
|
||||
* @param string $template
|
||||
* @param array $data
|
||||
* @param HtmlView|null $view
|
||||
* @param int $code
|
||||
* @return void
|
||||
*/
|
||||
protected function outputHTML($template, array $data = [], $view = NULL)
|
||||
protected function outputHTML($template, array $data = [], $view = NULL, $code = 200)
|
||||
{
|
||||
if (is_null($view))
|
||||
{
|
||||
$view = new HtmlView($this->container);
|
||||
}
|
||||
|
||||
$view->setStatusCode($code);
|
||||
$this->render_full_page($view, $template, $data);
|
||||
}
|
||||
|
||||
|
@ -113,11 +113,13 @@ class Dispatcher extends RoutingBase {
|
||||
switch(TRUE)
|
||||
{
|
||||
case $failure->failedMethod():
|
||||
$params['http_code'] = 405;
|
||||
$params['title'] = '405 Method Not Allowed';
|
||||
$params['message'] = 'Invalid HTTP Verb';
|
||||
break;
|
||||
|
||||
case $failure->failedAccept():
|
||||
$params['http_code'] = 406;
|
||||
$params['title'] = '406 Not Acceptable';
|
||||
$params['message'] = 'Unacceptable content type';
|
||||
break;
|
||||
|
@ -72,7 +72,7 @@ abstract class View {
|
||||
{
|
||||
$this->send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return rendered output
|
||||
@ -119,28 +119,11 @@ abstract class View {
|
||||
public function getOutput()
|
||||
{
|
||||
return $this->string($this->output)->__toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send output to client
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$this->hasRendered = TRUE;
|
||||
$this->output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the appropriate response
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function output()
|
||||
{
|
||||
$content =& $this->response->content;
|
||||
$content->set($this->output);
|
||||
$content->setType($this->contentType);
|
||||
$content->setCharset('utf-8');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send output to client
|
||||
*/
|
||||
abstract public function send();
|
||||
}
|
||||
// End of View.php
|
@ -31,20 +31,44 @@ class HttpView extends BaseView {
|
||||
public function redirect($url, $code)
|
||||
{
|
||||
$this->response->redirect->to($url, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the appropriate response
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
* @return void
|
||||
*/
|
||||
protected function output()
|
||||
{
|
||||
parent::output();
|
||||
|
||||
$sender = new ResponseSender($this->response);
|
||||
$sender->__invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the status code of the request
|
||||
*
|
||||
* @param int $code
|
||||
* @return HttpView
|
||||
*/
|
||||
public function setStatusCode($code)
|
||||
{
|
||||
$this->response->status->setCode($code);
|
||||
$this->response->status->setVersion(1.1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send output to client
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
$this->hasRendered = TRUE;
|
||||
$this->output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the appropriate response
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function output()
|
||||
{
|
||||
$content =& $this->response->content;
|
||||
$content->set($this->output);
|
||||
$content->setType($this->contentType);
|
||||
$content->setCharset('utf-8');
|
||||
|
||||
$sender = new ResponseSender($this->response);
|
||||
$sender->__invoke();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user