Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
7 changed files with 60 additions and 57 deletions
Showing only changes of commit 28adcaf95a - Show all commits

View File

@ -6,12 +6,13 @@
namespace Aviat\AnimeClient;
use Aura\Html\HelperLocatorFactory;
use Aura\Web\WebFactory;
use Aura\Router\RouterFactory;
use Aura\Router\RouterContainer;
use Aura\Session\SessionFactory;
use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\BrowserConsoleHandler;
use Zend\Diactoros\ServerRequestFactory;
use Zend\Diactoros\Response;
use Aviat\Ion\Di\Container;
use Aviat\AnimeClient\Auth\HummingbirdAuth;
@ -40,8 +41,7 @@ return function(array $config_array = []) {
$container->set('config', $config);
// Create Aura Router Object
$aura_router = (new RouterFactory())->newInstance();
$container->set('aura-router', $aura_router);
$container->set('aura-router', new RouterContainer);
// Create Html helper Object
$html_helper = (new HelperLocatorFactory)->newInstance();
@ -53,15 +53,15 @@ return function(array $config_array = []) {
$container->set('html-helper', $html_helper);
// Create Request/Response Objects
$web_factory = new WebFactory([
'_GET' => $_GET,
'_POST' => $_POST,
'_COOKIE' => $_COOKIE,
'_SERVER' => $_SERVER,
'_FILES' => $_FILES
]);
$container->set('request', $web_factory->newRequest());
$container->set('response', $web_factory->newResponse());
$request = ServerRequestFactory::fromGlobals(
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
);
$container->set('request', $request);
$container->set('response', new Response());
// Create session Object
$session = (new SessionFactory())->newInstance($_COOKIE);

View File

@ -5,18 +5,19 @@
"require": {
"abeautifulsite/simpleimage": "2.5.*",
"aura/html": "2.*",
"aura/router": "2.2.*",
"aura/router": "3.*",
"aura/session": "2.*",
"aura/web": "2.*",
"aviat4ion/query": "2.5.*",
"container-interop/container-interop": "1.*",
"danielstjules/stringy": "~2.1",
"filp/whoops": "2.0.*",
"guzzlehttp/guzzle": "6.*",
"monolog/monolog": "1.*",
"psr/http-message": "~1.0",
"psr/log": "~1.0",
"robmorgan/phinx": "0.4.*",
"yosymfony/toml": "0.3.*"
"yosymfony/toml": "0.3.*",
"zendframework/zend-diactoros": "1.3.*"
},
"require-dev": {
"codeclimate/php-test-reporter": "dev-master"

View File

@ -95,7 +95,7 @@ class Controller {
$this->session = $session->getSegment(AnimeClient::SESSION_SEGMENT);
// Set a 'previous' flash value for better redirects
$this->session->setFlash('previous', $this->request->server->get('HTTP_REFERER'));
$this->session->setFlash('previous', $this->request->getServerParams()['HTTP_REFERER']);
// Set a message box if available
$this->base_data['message'] = $this->session->getFlash('message');
@ -130,7 +130,7 @@ class Controller {
public function set_session_redirect($url = NULL)
{
$anime_client = $this->container->get('anime-client');
$double_form_page = $this->request->server->get('HTTP_REFERER') == $this->request->url->get();
$double_form_page = $this->request->getServerParams()['HTTP_REFERER'] == $this->request->getUri();
// Don't attempt to set the redirect url if
// the page is one of the form type pages,
@ -144,7 +144,7 @@ class Controller {
{
$url = ($anime_client->is_view_page())
? $this->request->url->get()
: $this->request->server->get('HTTP_REFERER');
: $this->request->getServerParams()['HTTP_REFERER'];
}
$this->session->set('redirect_url', $url);

View File

@ -29,6 +29,12 @@ class Dispatcher extends RoutingBase {
*/
protected $router;
/**
* The route matcher
* @var object $matcher
*/
protected $matcher;
/**
* Class wrapper for input superglobals
* @var object
@ -49,7 +55,8 @@ class Dispatcher extends RoutingBase {
public function __construct(ContainerInterface $container)
{
parent::__construct($container);
$this->router = $container->get('aura-router');
$this->router = $container->get('aura-router')->getMap();
$this->matcher = $container->get('aura-router')->getMatcher();
$this->request = $container->get('request');
$this->output_routes = $this->_setup_routes();
@ -64,7 +71,7 @@ class Dispatcher extends RoutingBase {
{
$logger = $this->container->getLogger('default');
$raw_route = $this->request->url->get(PHP_URL_PATH);
$raw_route = $this->request->getUri()->getPath();
$route_path = "/" . trim($raw_route, '/');
$logger->debug('Dispatcher - Routing data from get_route method');
@ -72,7 +79,7 @@ class Dispatcher extends RoutingBase {
'route_path' => $route_path
], TRUE));
return $this->router->match($route_path, $_SERVER);
return $this->matcher->match($this->request);
}
/**
@ -134,9 +141,9 @@ class Dispatcher extends RoutingBase {
*/
protected function process_route($route)
{
if (array_key_exists('controller', $route->params))
if (array_key_exists('controller', $route->attributes))
{
$controller_name = $route->params['controller'];
$controller_name = $route->attributes['controller'];
}
else
{
@ -150,21 +157,21 @@ class Dispatcher extends RoutingBase {
$controller_name = $map[$controller_name];
}
$action_method = (array_key_exists('action', $route->params))
? $route->params['action']
$action_method = (array_key_exists('action', $route->attributes))
? $route->attributes['action']
: AnimeClient::NOT_FOUND_METHOD;
$params = (array_key_exists('params', $route->params))
? $route->params['params']
$params = (array_key_exists('params', $route->attributes))
? $route->attributes['params']
: [];
if ( ! empty($route->tokens))
{
foreach ($route->tokens as $key => $v)
{
if (array_key_exists($key, $route->params))
if (array_key_exists($key, $route->attributes))
{
$params[$key] = $route->params[$key];
$params[$key] = $route->attributes[$key];
}
}
}
@ -184,7 +191,7 @@ class Dispatcher extends RoutingBase {
public function get_controller()
{
$route_type = $this->__get('default_list');
$request_uri = $this->request->url->get(PHP_URL_PATH);
$request_uri = $this->request->getUri()->getPath();
$path = trim($request_uri, '/');
$segments = explode('/', $path);
@ -323,15 +330,15 @@ class Dispatcher extends RoutingBase {
// Select the appropriate router method based on the http verb
$add = (array_key_exists('verb', $route))
? "add" . ucfirst(strtolower($route['verb']))
: "addGet";
? strtolower($route['verb'])
: "get";
// 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);//->addValues($route);
}
else
/*else
{
$tokens = $route['tokens'];
unset($route['tokens']);
@ -339,7 +346,7 @@ class Dispatcher extends RoutingBase {
$routes[] = $this->router->$add($name, $path)
->addValues($route)
->addTokens($tokens);
}
}*/
}
return $routes;

View File

@ -32,7 +32,7 @@ class UrlGenerator extends RoutingBase {
public function __construct(ContainerInterface $container)
{
parent::__construct($container);
$this->host = $container->get('request')->server->get('HTTP_HOST');
$this->host = $container->get('request')->getServerParams()['HTTP_HOST'];
}
/**

View File

@ -26,7 +26,7 @@ abstract class View {
/**
* HTTP response Object
*
* @var Aura\Web\Response
* @var Zend\Diactoros\Response
*/
protected $response;
@ -93,7 +93,7 @@ abstract class View {
*/
public function setOutput($string)
{
$this->output = $this->string($string);
$this->response->getBody()->write($string);
return $this;
}
@ -106,7 +106,7 @@ abstract class View {
*/
public function appendOutput($string)
{
$this->output = $this->string($this->output)->append($string);
$this->response->getBody()->write($string);
return $this;
}
@ -118,7 +118,7 @@ abstract class View {
*/
public function getOutput()
{
return $this->string($this->output)->__toString();
return $this->response->getBody()->__toString();
}
/**

View File

@ -12,8 +12,7 @@
namespace Aviat\Ion\View;
use Aura\Web\ResponseSender;
use Zend\Diactoros\Response\SapiEmitter;
use Aviat\Ion\View as BaseView;
/**
@ -41,8 +40,8 @@ class HttpView extends BaseView {
*/
public function setStatusCode($code)
{
$this->response->status->setCode($code);
$this->response->status->setVersion(1.1);
$this->response->withStatus($code);
$this->response->withProtocolVersion(1.1);
return $this;
}
@ -65,18 +64,14 @@ class HttpView extends BaseView {
*/
protected function output()
{
$this->response->headers->set('Content-Security-Policy', "script-src 'self'");
$this->response->headers->set('X-Content-Type-Options', 'nosniff');
$this->response->headers->set('X-XSS-Protection', '1;mode=block');
$this->response->headers->set('X-Frame-Options', 'SAMEORIGIN');
$this->response->withHeader('Content-type', "{$this->contentType};charset=utf-8")
->withHeader('Content-Security-Policy', "script-src 'self'")
->withHeader('X-Content-Type-Options', 'nosniff')
->withHeader('X-XSS-Protection', '1;mode=block')
->withHeader('X-Frame-Options', 'SAMEORIGIN');
$content =& $this->response->content;
$content->set($this->output);
$content->setType($this->contentType);
$content->setCharset('utf-8');
$sender = new ResponseSender($this->response);
$sender->__invoke();
$sender = new SapiEmitter($this->response);
$sender->emit();
}
}