Namespace refactoring
This commit is contained in:
parent
67799fcdfa
commit
b1c6039630
@ -3,7 +3,7 @@
|
||||
* Bootstrap / Dependency Injection
|
||||
*/
|
||||
|
||||
namespace AnimeClient;
|
||||
namespace Aviat\AnimeClient;
|
||||
|
||||
use \Whoops\Handler\PrettyPageHandler;
|
||||
use \Whoops\Handler\JsonResponseHandler;
|
||||
|
@ -70,25 +70,6 @@ return [
|
||||
'code' => '301'
|
||||
]
|
||||
],
|
||||
'login_form' => [
|
||||
'path' => '/anime/login',
|
||||
'action' => ['login'],
|
||||
'verb' => 'get'
|
||||
],
|
||||
'login_action' => [
|
||||
'path' => '/anime/login',
|
||||
'action' => ['login_action'],
|
||||
'verb' => 'post'
|
||||
],
|
||||
'logout' => [
|
||||
'path' => '/anime/logout',
|
||||
'action' => ['logout']
|
||||
],
|
||||
'update' => [
|
||||
'path' => '/anime/update',
|
||||
'action' => ['update'],
|
||||
'verb' => 'post'
|
||||
],
|
||||
'search' => [
|
||||
'path' => '/anime/search',
|
||||
'action' => ['search'],
|
||||
|
@ -54,7 +54,6 @@ function _setup_autoloaders()
|
||||
require _dir(ROOT_DIR, '/vendor/autoload.php');
|
||||
spl_autoload_register(function ($class) {
|
||||
$class_parts = explode('\\', $class);
|
||||
array_shift($class_parts);
|
||||
$ns_path = SRC_DIR . '/' . implode('/', $class_parts) . ".php";
|
||||
|
||||
if (file_exists($ns_path))
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Base Configuration class
|
||||
*/
|
||||
|
||||
namespace AnimeClient\Base;
|
||||
namespace Aviat\AnimeClient\Base;
|
||||
|
||||
/**
|
||||
* Wrapper for configuration values
|
11
src/Aviat/AnimeClient/Base/Container.php
Normal file
11
src/Aviat/AnimeClient/Base/Container.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Aviat\AnimeClient\Base;
|
||||
|
||||
/**
|
||||
* Dependency container
|
||||
*/
|
||||
class Container extends \Aviat\Ion\Base\Container {
|
||||
|
||||
}
|
||||
// End of Container.php
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Base Controller
|
||||
*/
|
||||
namespace AnimeClient\Base;
|
||||
namespace Aviat\AnimeClient\Base;
|
||||
|
||||
/**
|
||||
* Base class for controllers, defines output methods
|
||||
@ -116,7 +116,7 @@ class Controller {
|
||||
|
||||
$defaultHandler->addDataTable('Template Data', $data);
|
||||
|
||||
$template_path = _dir(SRC_DIR, 'views', "{$template}.php");
|
||||
$template_path = _dir(APP_DIR, 'views', "{$template}.php");
|
||||
|
||||
if ( ! is_file($template_path))
|
||||
{
|
||||
@ -125,9 +125,9 @@ class Controller {
|
||||
|
||||
ob_start();
|
||||
extract($data);
|
||||
include _dir(SRC_DIR, 'views', 'header.php');
|
||||
include _dir(APP_DIR, 'views', 'header.php');
|
||||
include $template_path;
|
||||
include _dir(SRC_DIR, 'views', 'footer.php');
|
||||
include _dir(APP_DIR, 'views', 'footer.php');
|
||||
$buffer = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Base for base models
|
||||
*/
|
||||
namespace AnimeClient\Base;
|
||||
namespace Aviat\AnimeClient\Base;
|
||||
|
||||
use abeautifulsite\SimpleImage;
|
||||
|
@ -2,16 +2,16 @@
|
||||
/**
|
||||
* Base API Model
|
||||
*/
|
||||
namespace AnimeClient\Base\Model;
|
||||
namespace Aviat\AnimeClient\Base\Model;
|
||||
|
||||
use \GuzzleHttp\Client;
|
||||
use \GuzzleHttp\Cookie\CookieJar;
|
||||
use \AnimeClient\Base\Container;
|
||||
use \Aviat\AnimeClient\Base\Container;
|
||||
|
||||
/**
|
||||
* Base model for api interaction
|
||||
*/
|
||||
class API extends \AnimeClient\Base\Model {
|
||||
class API extends \Aviat\AnimeClient\Base\Model {
|
||||
|
||||
/**
|
||||
* Base url for making api requests
|
@ -2,14 +2,14 @@
|
||||
/**
|
||||
* Base DB model
|
||||
*/
|
||||
namespace AnimeClient\Base\Model;
|
||||
namespace Aviat\AnimeClient\Base\Model;
|
||||
|
||||
use AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Base\Container;
|
||||
|
||||
/**
|
||||
* Base model for database interaction
|
||||
*/
|
||||
class DB extends \AnimeClient\Base\Model {
|
||||
class DB extends \Aviat\AnimeClient\Base\Model {
|
||||
/**
|
||||
* The query builder object
|
||||
* @var object $db
|
@ -2,10 +2,10 @@
|
||||
/**
|
||||
* Routing logic
|
||||
*/
|
||||
namespace AnimeClient\Base;
|
||||
namespace Aviat\AnimeClient\Base;
|
||||
|
||||
use \Aura\Web\Request;
|
||||
use \Aura\Web\Response;
|
||||
use Aura\Web\Request;
|
||||
use Aura\Web\Response;
|
||||
|
||||
/**
|
||||
* Basic routing/ dispatch
|
||||
@ -39,10 +39,7 @@ class Router extends RoutingBase {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Config $config
|
||||
* @param Router $router
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
* @param Container $container
|
||||
*/
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
@ -179,7 +176,7 @@ class Router extends RoutingBase {
|
||||
$path = $route['path'];
|
||||
unset($route['path']);
|
||||
|
||||
$controller_class = '\\AnimeClient\\Controller\\' . ucfirst($route_type);
|
||||
$controller_class = '\\Aviat\\AnimeClient\\Controller\\' . ucfirst($route_type);
|
||||
|
||||
// Prepend the controller to the route parameters
|
||||
array_unshift($route['action'], $controller_class);
|
@ -1,7 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Base class for routing to make namespaced config settings
|
||||
* easier to work with
|
||||
*/
|
||||
namespace Aviat\AnimeClient\Base;
|
||||
|
||||
namespace AnimeClient\Base;
|
||||
|
||||
/**
|
||||
* Base for routing/url classes
|
||||
*/
|
||||
class RoutingBase {
|
||||
/**
|
||||
* Injection Container
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace AnimeClient\Base;
|
||||
/**
|
||||
* Generate full urls from fragments
|
||||
*/
|
||||
namespace Aviat\AnimeClient\Base;
|
||||
|
||||
/**
|
||||
* UrlGenerator class.
|
@ -3,13 +3,13 @@
|
||||
* Anime Controller
|
||||
*/
|
||||
|
||||
namespace AnimeClient\Controller;
|
||||
namespace Aviat\AnimeClient\Controller;
|
||||
|
||||
use AnimeClient\Base\Container;
|
||||
use AnimeClient\Base\Controller as BaseController;
|
||||
use AnimeClient\Base\Config;
|
||||
use AnimeClient\Model\Anime as AnimeModel;
|
||||
use AnimeClient\Model\AnimeCollection as AnimeCollectionModel;
|
||||
use Aviat\AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Base\Controller as BaseController;
|
||||
use Aviat\AnimeClient\Base\Config;
|
||||
use Aviat\AnimeClient\Model\Anime as AnimeModel;
|
||||
use Aviat\AnimeClient\Model\AnimeCollection as AnimeCollectionModel;
|
||||
|
||||
/**
|
||||
* Controller for Anime-related pages
|
@ -3,13 +3,13 @@
|
||||
* Anime Collection Controller
|
||||
*/
|
||||
|
||||
namespace AnimeClient\Controller;
|
||||
namespace Aviat\AnimeClient\Controller;
|
||||
|
||||
use AnimeClient\Base\Container;
|
||||
use AnimeClient\Base\Controller as BaseController;
|
||||
use AnimeClient\Base\Config;
|
||||
use AnimeClient\Model\Anime as AnimeModel;
|
||||
use AnimeClient\Model\AnimeCollection as AnimeCollectionModel;
|
||||
use Aviat\AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Base\Controller as BaseController;
|
||||
use Aviat\AnimeClient\Base\Config;
|
||||
use Aviat\AnimeClient\Model\Anime as AnimeModel;
|
||||
use Aviat\AnimeClient\Model\AnimeCollection as AnimeCollectionModel;
|
||||
|
||||
/**
|
||||
* Controller for Anime collection pages
|
||||
@ -44,6 +44,8 @@ class Collection extends BaseController {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Container $container
|
||||
*/
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
@ -78,6 +80,7 @@ class Collection extends BaseController {
|
||||
/**
|
||||
* Show the anime collection page
|
||||
*
|
||||
* @param string $view
|
||||
* @return void
|
||||
*/
|
||||
public function index($view)
|
@ -2,12 +2,12 @@
|
||||
/**
|
||||
* Manga Controller
|
||||
*/
|
||||
namespace AnimeClient\Controller;
|
||||
namespace Aviat\AnimeClient\Controller;
|
||||
|
||||
use AnimeClient\Base\Container;
|
||||
use AnimeClient\Base\Controller;
|
||||
use AnimeClient\Base\Config;
|
||||
use AnimeClient\Model\Manga as MangaModel;
|
||||
use Aviat\AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Base\Controller;
|
||||
use Aviat\AnimeClient\Base\Config;
|
||||
use Aviat\AnimeClient\Model\Manga as MangaModel;
|
||||
|
||||
/**
|
||||
* Controller for manga list
|
||||
@ -42,6 +42,8 @@ class Manga extends Controller {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Container $container
|
||||
*/
|
||||
public function __construct(Container $container)
|
||||
{
|
11
src/Aviat/AnimeClient/Controller/Stats.php
Normal file
11
src/Aviat/AnimeClient/Controller/Stats.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Aviat\AnimeClient\Controller;
|
||||
|
||||
use Aviat\AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Base\Controller;
|
||||
|
||||
class Stats extends Controller {
|
||||
|
||||
}
|
||||
// End of Stats.php
|
@ -3,9 +3,9 @@
|
||||
* Anime API Model
|
||||
*/
|
||||
|
||||
namespace AnimeClient\Model;
|
||||
namespace Aviat\AnimeClient\Model;
|
||||
|
||||
use AnimeClient\Base\Model\API;
|
||||
use Aviat\AnimeClient\Base\Model\API;
|
||||
|
||||
/**
|
||||
* Model for handling requests dealing with the anime list
|
@ -3,11 +3,11 @@
|
||||
* Anime Collection DB Model
|
||||
*/
|
||||
|
||||
namespace AnimeClient\Model;
|
||||
namespace Aviat\AnimeClient\Model;
|
||||
|
||||
use AnimeClient\Base\Model\DB;
|
||||
use \AnimeClient\Base\Container;
|
||||
use AnimeClient\Model\Anime as AnimeModel;
|
||||
use Aviat\AnimeClient\Base\Model\DB;
|
||||
use \Aviat\AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Model\Anime as AnimeModel;
|
||||
|
||||
/**
|
||||
* Model for getting anime collection data
|
@ -2,9 +2,9 @@
|
||||
/**
|
||||
* Manga API Model
|
||||
*/
|
||||
namespace AnimeClient\Model;
|
||||
namespace Aviat\AnimeClient\Model;
|
||||
|
||||
use AnimeClient\Base\Model\API;
|
||||
use Aviat\AnimeClient\Base\Model\API;
|
||||
|
||||
/**
|
||||
* Model for handling requests dealing with the manga list
|
@ -3,10 +3,10 @@
|
||||
* Anime API Model
|
||||
*/
|
||||
|
||||
namespace AnimeClient\Model;
|
||||
namespace Aviat\AnimeClient\Model;
|
||||
|
||||
use AnimeClient\Base\Model\DB;
|
||||
use AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Base\Model\DB;
|
||||
use Aviat\AnimeClient\Base\Container;
|
||||
|
||||
use StatsChartsTrait;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace AnimeClient\Model;
|
||||
namespace Aviat\AnimeClient\Model;
|
||||
|
||||
use CpChart\Services\pChartFactory;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace AnimeClient\Base;
|
||||
namespace Aviat\Ion\Base;
|
||||
|
||||
/**
|
||||
* Wrapper of Aura container to be in the anime client namespace
|
||||
* Dependency container
|
||||
*/
|
||||
class Container {
|
||||
|
72
src/Aviat/Ion/Base/Page.php
Normal file
72
src/Aviat/Ion/Base/Page.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Aviat\Ion\Base;
|
||||
|
||||
use Aura\Web\Request;
|
||||
use Aura\Web\Response;
|
||||
|
||||
class Page {
|
||||
|
||||
/**
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var Response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* __construct function.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Response $response
|
||||
*/
|
||||
public function __construct(Request $request, Response $response)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* __destruct function.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the response to the client
|
||||
*/
|
||||
protected function output()
|
||||
{
|
||||
// send status
|
||||
@header($this->response->status->get(), true, $this->response->status->getCode());
|
||||
|
||||
// headers
|
||||
foreach($this->response->headers->get() as $label => $value)
|
||||
{
|
||||
@header("{$label}: {$value}");
|
||||
}
|
||||
|
||||
// cookies
|
||||
foreach($this->response->cookies->get() as $name => $cookie)
|
||||
{
|
||||
@setcookie(
|
||||
$name,
|
||||
$cookie['value'],
|
||||
$cookie['expire'],
|
||||
$cookie['path'],
|
||||
$cookie['domain'],
|
||||
$cookie['secure'],
|
||||
$cookie['httponly']
|
||||
);
|
||||
}
|
||||
|
||||
// send the actual response
|
||||
echo $this->response->content->get();
|
||||
}
|
||||
}
|
||||
// End of Page.php
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace AnimeClient\Controller;
|
||||
|
||||
use AnimeClient\Base\Container;
|
||||
use AnimeClient\Base\Controller;
|
||||
|
||||
class Stats extends Controller {
|
||||
|
||||
}
|
||||
// End of Stats.php
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
use \AnimeClient\Base\Controller;
|
||||
use \Aviat\AnimeClient\Base\Controller;
|
||||
use \Aura\Web\WebFactory;
|
||||
use \Aura\Router\RouterFactory;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use AnimeClient\Base\Model as BaseModel;
|
||||
use AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Base\Model as BaseModel;
|
||||
use Aviat\AnimeClient\Base\Container;
|
||||
|
||||
class BaseModelTest extends AnimeClient_TestCase {
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use \AnimeClient\Base\Config;
|
||||
use \Aviat\AnimeClient\Base\Config;
|
||||
|
||||
class ConfigTest extends AnimeClient_TestCase {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
use AnimeClient\Base\Container;
|
||||
use AnimeClient\Base\Model\API as BaseApiModel;
|
||||
use Aviat\AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Base\Model\API as BaseApiModel;
|
||||
|
||||
class MockBaseApiModel extends BaseApiModel {
|
||||
|
||||
@ -23,8 +23,8 @@ class BaseApiModelTest extends AnimeClient_TestCase {
|
||||
$baseApiModel = new MockBaseApiModel($this->container);
|
||||
|
||||
// Some basic type checks for class memebers
|
||||
$this->assertInstanceOf('\AnimeClient\Base\Model', $baseApiModel);
|
||||
$this->assertInstanceOf('\AnimeClient\Base\Model\API', $baseApiModel);
|
||||
$this->assertInstanceOf('\Aviat\AnimeClient\Base\Model', $baseApiModel);
|
||||
$this->assertInstanceOf('\Aviat\AnimeClient\Base\Model\API', $baseApiModel);
|
||||
|
||||
$this->assertInstanceOf('\GuzzleHttp\Client', $baseApiModel->client);
|
||||
$this->assertInstanceOf('\GuzzleHttp\Cookie\CookieJar', $baseApiModel->cookieJar);
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use AnimeClient\Base\Model\DB as BaseDBModel;
|
||||
use Aviat\AnimeClient\Base\Model\DB as BaseDBModel;
|
||||
|
||||
class BaseDBModelTest extends AnimeClient_TestCase {
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
use AnimeClient\Base\Router;
|
||||
use AnimeClient\Base\Config;
|
||||
use AnimeClient\Base\Container;
|
||||
use AnimeClient\Base\UrlGenerator;
|
||||
use Aviat\AnimeClient\Base\Router;
|
||||
use Aviat\AnimeClient\Base\Config;
|
||||
use Aviat\AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Base\UrlGenerator;
|
||||
use Aura\Web\WebFactory;
|
||||
use Aura\Router\RouterFactory;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use AnimeClient\Base\Config;
|
||||
use AnimeClient\Base\Container;
|
||||
use AnimeClient\Base\UrlGenerator;
|
||||
use Aviat\AnimeClient\Base\Config;
|
||||
use Aviat\AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Base\UrlGenerator;
|
||||
|
||||
class UrlGeneratorTest extends AnimeClient_TestCase {
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
* Global setup for unit tests
|
||||
*/
|
||||
|
||||
use AnimeClient\Base\Config;
|
||||
use AnimeClient\Base\Container;
|
||||
use Aviat\AnimeClient\Base\Config;
|
||||
use Aviat\AnimeClient\Base\Container;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Mock the default error handler
|
||||
@ -85,7 +85,6 @@ function _setup_autoloaders()
|
||||
require _dir(ROOT_DIR, '/vendor/autoload.php');
|
||||
spl_autoload_register(function ($class) {
|
||||
$class_parts = explode('\\', $class);
|
||||
array_shift($class_parts);
|
||||
$ns_path = SRC_DIR . '/' . implode('/', $class_parts) . ".php";
|
||||
|
||||
if (file_exists($ns_path))
|
||||
|
Loading…
Reference in New Issue
Block a user