Version 5.1 - All the GraphQL #32
@ -95,7 +95,11 @@ class Controller {
|
|||||||
$this->session = $session->getSegment(AnimeClient::SESSION_SEGMENT);
|
$this->session = $session->getSegment(AnimeClient::SESSION_SEGMENT);
|
||||||
|
|
||||||
// Set a 'previous' flash value for better redirects
|
// Set a 'previous' flash value for better redirects
|
||||||
$this->session->setFlash('previous', $this->request->getServerParams()['HTTP_REFERER']);
|
$server_params = $this->request->getServerParams();
|
||||||
|
if (array_key_exists('HTTP_REFERER', $server_params))
|
||||||
|
{
|
||||||
|
$this->session->setFlash('previous', $server_params['HTTP_REFERER']);
|
||||||
|
}
|
||||||
|
|
||||||
// Set a message box if available
|
// Set a message box if available
|
||||||
$this->base_data['message'] = $this->session->getFlash('message');
|
$this->base_data['message'] = $this->session->getFlash('message');
|
||||||
@ -274,7 +278,8 @@ class Controller {
|
|||||||
public function login_action()
|
public function login_action()
|
||||||
{
|
{
|
||||||
$auth = $this->container->get('auth');
|
$auth = $this->container->get('auth');
|
||||||
if ($auth->authenticate($this->request->post->get('password')))
|
$post = $this->request->getParsedBody();
|
||||||
|
if ($auth->authenticate($post['password']))
|
||||||
{
|
{
|
||||||
return $this->session_redirect();
|
return $this->session_redirect();
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ class Anime extends BaseController {
|
|||||||
*/
|
*/
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
$data = $this->request->post->get();
|
$data = $this->request->getParsedBody();
|
||||||
if ( ! array_key_exists('id', $data))
|
if ( ! array_key_exists('id', $data))
|
||||||
{
|
{
|
||||||
$this->redirect("anime/add", 303);
|
$this->redirect("anime/add", 303);
|
||||||
@ -216,7 +216,7 @@ class Anime extends BaseController {
|
|||||||
*/
|
*/
|
||||||
public function form_update()
|
public function form_update()
|
||||||
{
|
{
|
||||||
$post_data = $this->request->post->get();
|
$post_data = $this->request->getParsedBody();
|
||||||
|
|
||||||
// Do some minor data manipulation for
|
// Do some minor data manipulation for
|
||||||
// large form-based updates
|
// large form-based updates
|
||||||
@ -247,7 +247,7 @@ class Anime extends BaseController {
|
|||||||
*/
|
*/
|
||||||
public function update()
|
public function update()
|
||||||
{
|
{
|
||||||
$response = $this->model->update($this->request->post->get());
|
$response = $this->model->update($this->request->getParsedBody());
|
||||||
$this->outputJSON($response['body'], $response['statusCode']);
|
$this->outputJSON($response['body'], $response['statusCode']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ class Anime extends BaseController {
|
|||||||
*/
|
*/
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
$response = $this->model->update($this->request->post->get());
|
$response = $this->model->update($this->request->getParsedBody());
|
||||||
$this->outputJSON($response['body'], $response['statusCode']);
|
$this->outputJSON($response['body'], $response['statusCode']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class Collection extends BaseController {
|
|||||||
*/
|
*/
|
||||||
public function edit()
|
public function edit()
|
||||||
{
|
{
|
||||||
$data = $this->request->post->get();
|
$data = $this->request->getParsedBody();
|
||||||
if (array_key_exists('hummingbird_id', $data))
|
if (array_key_exists('hummingbird_id', $data))
|
||||||
{
|
{
|
||||||
$this->anime_collection_model->update($data);
|
$this->anime_collection_model->update($data);
|
||||||
@ -151,7 +151,7 @@ class Collection extends BaseController {
|
|||||||
*/
|
*/
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
$data = $this->request->post->get();
|
$data = $this->request->getParsedBody();
|
||||||
if (array_key_exists('id', $data))
|
if (array_key_exists('id', $data))
|
||||||
{
|
{
|
||||||
$this->anime_collection_model->add($data);
|
$this->anime_collection_model->add($data);
|
||||||
@ -172,7 +172,7 @@ class Collection extends BaseController {
|
|||||||
*/
|
*/
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
$data = $this->request->post->get();
|
$data = $this->request->getParsedBody();
|
||||||
if ( ! array_key_exists('id', $data))
|
if ( ! array_key_exists('id', $data))
|
||||||
{
|
{
|
||||||
$this->redirect("collection/view", 303);
|
$this->redirect("collection/view", 303);
|
||||||
|
@ -127,7 +127,7 @@ class Manga extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
$data = $this->request->post->get();
|
$data = $this->request->getParsedBody();
|
||||||
if ( ! array_key_exists('id', $data))
|
if ( ! array_key_exists('id', $data))
|
||||||
{
|
{
|
||||||
$this->redirect("manga/add", 303);
|
$this->redirect("manga/add", 303);
|
||||||
@ -176,8 +176,8 @@ class Manga extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function search()
|
public function search()
|
||||||
{
|
{
|
||||||
$query = $this->request->query->get('query');
|
$query_data = $this->request->getQueryParams();
|
||||||
$this->outputJSON($this->model->search($query));
|
$this->outputJSON($this->model->search($query_data['query']));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,7 +187,7 @@ class Manga extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function form_update()
|
public function form_update()
|
||||||
{
|
{
|
||||||
$post_data = $this->request->post->get();
|
$post_data = $this->request->getParsedBody();
|
||||||
|
|
||||||
// Do some minor data manipulation for
|
// Do some minor data manipulation for
|
||||||
// large form-based updates
|
// large form-based updates
|
||||||
@ -221,7 +221,7 @@ class Manga extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function update()
|
public function update()
|
||||||
{
|
{
|
||||||
$result = $this->model->update($this->request->post->get());
|
$result = $this->model->update($this->request->getParsedBody());
|
||||||
$this->outputJSON($result['body'], $result['statusCode']);
|
$this->outputJSON($result['body'], $result['statusCode']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ class Dispatcher extends RoutingBase {
|
|||||||
protected function get_error_params()
|
protected function get_error_params()
|
||||||
{
|
{
|
||||||
$logger = $this->container->getLogger('default');
|
$logger = $this->container->getLogger('default');
|
||||||
$failure = $this->router->getFailedRoute();
|
$failure = $this->matcher->getFailedRoute();
|
||||||
|
|
||||||
$logger->info('Dispatcher - failed route');
|
$logger->info('Dispatcher - failed route');
|
||||||
$logger->info(print_r($failure, TRUE));
|
$logger->info(print_r($failure, TRUE));
|
||||||
@ -271,26 +271,27 @@ class Dispatcher extends RoutingBase {
|
|||||||
|
|
||||||
$params = [];
|
$params = [];
|
||||||
|
|
||||||
if ($failure->failedMethod())
|
switch($failure->failedRule) {
|
||||||
{
|
case 'Aura\Router\Rule\Alows':
|
||||||
$params = [
|
$params = [
|
||||||
'http_code' => 405,
|
'http_code' => 405,
|
||||||
'title' => '405 Method Not Allowed',
|
'title' => '405 Method Not Allowed',
|
||||||
'message' => 'Invalid HTTP Verb'
|
'message' => 'Invalid HTTP Verb'
|
||||||
];
|
];
|
||||||
}
|
break;
|
||||||
else if ($failure->failedAccept())
|
|
||||||
{
|
case 'Aura\Router\Rule\Accepts':
|
||||||
$params = [
|
$params = [
|
||||||
'http_code' => 406,
|
'http_code' => 406,
|
||||||
'title' => '406 Not Acceptable',
|
'title' => '406 Not Acceptable',
|
||||||
'message' => 'Unacceptable content type'
|
'message' => 'Unacceptable content type'
|
||||||
];
|
];
|
||||||
}
|
break;
|
||||||
else
|
|
||||||
{
|
default:
|
||||||
// Fall back to a 404 message
|
// Fall back to a 404 message
|
||||||
$action_method = AnimeClient::NOT_FOUND_METHOD;
|
$action_method = AnimeClient::NOT_FOUND_METHOD;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -334,19 +335,19 @@ class Dispatcher extends RoutingBase {
|
|||||||
: "get";
|
: "get";
|
||||||
|
|
||||||
// Add the route to the router object
|
// Add the route to the router object
|
||||||
//if ( ! array_key_exists('tokens', $route))
|
if ( ! array_key_exists('tokens', $route))
|
||||||
{
|
{
|
||||||
$routes[] = $this->router->$add($name, $path);//->addValues($route);
|
$routes[] = $this->router->$add($name, $path)->defaults($route);
|
||||||
}
|
}
|
||||||
/*else
|
else
|
||||||
{
|
{
|
||||||
$tokens = $route['tokens'];
|
$tokens = $route['tokens'];
|
||||||
unset($route['tokens']);
|
unset($route['tokens']);
|
||||||
|
|
||||||
$routes[] = $this->router->$add($name, $path)
|
$routes[] = $this->router->$add($name, $path)
|
||||||
->addValues($route)
|
->defaults($route)
|
||||||
->addTokens($tokens);
|
->tokens($tokens);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $routes;
|
return $routes;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
namespace Aviat\Ion\View;
|
namespace Aviat\Ion\View;
|
||||||
|
|
||||||
|
use Zend\Diactoros\Response;
|
||||||
use Zend\Diactoros\Response\SapiEmitter;
|
use Zend\Diactoros\Response\SapiEmitter;
|
||||||
use Aviat\Ion\View as BaseView;
|
use Aviat\Ion\View as BaseView;
|
||||||
|
|
||||||
@ -29,8 +30,15 @@ class HttpView extends BaseView {
|
|||||||
*/
|
*/
|
||||||
public function redirect($url, $code)
|
public function redirect($url, $code)
|
||||||
{
|
{
|
||||||
$this->response->withStatus($code);
|
ob_start();
|
||||||
$this->response->withHeader('Location', $url);
|
$response = new Response();
|
||||||
|
$message = $response->getReasonPhrase($code);
|
||||||
|
|
||||||
|
header("HTTP/1.1 ${code} ${message}");
|
||||||
|
header("Location: {$url}");
|
||||||
|
|
||||||
|
$this->hasRendered = TRUE;
|
||||||
|
ob_end_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,8 +49,8 @@ class HttpView extends BaseView {
|
|||||||
*/
|
*/
|
||||||
public function setStatusCode($code)
|
public function setStatusCode($code)
|
||||||
{
|
{
|
||||||
$this->response->withStatus($code);
|
$this->response->withStatus($code)
|
||||||
$this->response->withProtocolVersion(1.1);
|
->withProtocolVersion(1.1);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user