Yet more snake case to camel case
This commit is contained in:
parent
23d78c3b28
commit
1f6100c367
@ -110,21 +110,21 @@ class Kitsu {
|
||||
return [
|
||||
'name' => 'Crunchyroll',
|
||||
'link' => true,
|
||||
'logo' => '<svg class="streaming-logo" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg"><g fill="#F78B24" fill-rule="evenodd"><path d="M22.549 49.145c-.815-.077-2.958-.456-3.753-.663-6.873-1.79-12.693-6.59-15.773-13.009C1.335 31.954.631 28.807.633 24.788c.003-4.025.718-7.235 2.38-10.686 1.243-2.584 2.674-4.609 4.706-6.66 3.8-3.834 8.614-6.208 14.067-6.936 1.783-.239 5.556-.161 7.221.148 3.463.642 6.571 1.904 9.357 3.797 5.788 3.934 9.542 9.951 10.52 16.861.21 1.48.332 4.559.19 4.816-.077.14-.117-.007-.167-.615-.25-3.015-1.528-6.66-3.292-9.388C40.253 7.836 30.249 4.32 20.987 7.467c-7.15 2.43-12.522 8.596-13.997 16.06-.73 3.692-.51 7.31.658 10.882a21.426 21.426 0 0 0 13.247 13.518c1.475.515 3.369.944 4.618 1.047 1.496.122 1.119.239-.727.224-1.006-.008-2.013-.032-2.237-.053z"></path><path d="M27.685 46.1c-7.731-.575-14.137-6.455-15.474-14.204-.243-1.41-.29-4.047-.095-5.345 1.16-7.706 6.97-13.552 14.552-14.639 1.537-.22 4.275-.143 5.746.162 1.28.266 2.7.737 3.814 1.266l.865.411-.814.392c-2.936 1.414-4.748 4.723-4.323 7.892.426 3.173 2.578 5.664 5.667 6.56 1.112.322 2.812.322 3.925 0 1.438-.417 2.566-1.1 3.593-2.173.346-.362.652-.621.68-.576.027.046.106.545.176 1.11.171 1.395.07 4.047-.204 5.371-.876 4.218-3.08 7.758-6.463 10.374-3.2 2.476-7.434 3.711-11.645 3.399z"></path></g></svg>'
|
||||
'image' => 'streaming-logos/crunchyroll.svg',
|
||||
];
|
||||
|
||||
case 'www.funimation.com':
|
||||
return [
|
||||
'name' => 'Funimation',
|
||||
'link' => true,
|
||||
'logo' => '<svg class="streaming-logo" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg"><path d="M24.066.017a24.922 24.922 0 0 1 13.302 3.286 25.098 25.098 0 0 1 7.833 7.058 24.862 24.862 0 0 1 4.207 9.575c.82 4.001.641 8.201-.518 12.117a24.946 24.946 0 0 1-4.868 9.009 24.98 24.98 0 0 1-7.704 6.118 24.727 24.727 0 0 1-10.552 2.718A24.82 24.82 0 0 1 13.833 47.3c-5.815-2.872-10.408-8.107-12.49-14.25-2.162-6.257-1.698-13.375 1.303-19.28C5.483 8.07 10.594 3.55 16.602 1.435A24.94 24.94 0 0 1 24.066.017zm-8.415 33.31c.464 2.284 1.939 4.358 3.99 5.48 2.174 1.217 4.765 1.444 7.202 1.181 2.002-.217 3.986-.992 5.455-2.397 1.173-1.151 2.017-2.648 2.33-4.267-1.189-.027-2.378 0-3.566-.03-.568.082-1.137-.048-1.705.014-1.232.012-2.465.003-3.697-.01-.655.066-1.309-.035-1.963.013-1.166-.053-2.334.043-3.5-.025-1.515.08-3.03-.035-4.546.042z" fill="#411299" fill-rule="evenodd"></path></svg>'
|
||||
'image' => 'streaming-logos/funimation.svg',
|
||||
];
|
||||
|
||||
case 'www.hulu.com':
|
||||
return [
|
||||
'name' => 'Hulu',
|
||||
'link' => true,
|
||||
'logo' => '<svg class="streaming-logo" viewBox="0 0 34 50" xmlns="http://www.w3.org/2000/svg"><path d="M22.222 13.889h-11.11V0H0v50h11.111V27.778c0-1.39 1.111-2.778 2.778-2.778h5.555c1.39 0 2.778 1.111 2.778 2.778V50h11.111V25c0-6.111-5-11.111-11.11-11.111z" fill="#8BC34A" fill-rule="evenodd"></path></svg>'
|
||||
'image' => 'streaming-logos/hulu.svg',
|
||||
];
|
||||
|
||||
// Default to Netflix, because the API links are broken,
|
||||
@ -133,7 +133,7 @@ class Kitsu {
|
||||
return [
|
||||
'name' => 'Netflix',
|
||||
'link' => false,
|
||||
'logo' => '<svg class="streaming-logo" viewBox="0 0 26 50" xmlns="http://www.w3.org/2000/svg"><path d="M.057.258C2.518.253 4.982.263 7.446.253c2.858 7.76 5.621 15.556 8.456 23.324.523 1.441 1.003 2.897 1.59 4.312.078-9.209.01-18.42.034-27.631h7.763v46.36c-2.812.372-5.637.627-8.457.957-1.203-3.451-2.396-6.902-3.613-10.348-1.796-5.145-3.557-10.302-5.402-15.428.129 8.954.015 17.912.057 26.871-2.603.39-5.227.637-7.815 1.119C.052 33.279.06 16.768.057.258z" fill="#E21221" fill-rule="evenodd"></path></svg>'
|
||||
'image' => 'streaming-logos/netflix.svg',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -107,10 +107,10 @@ class Controller {
|
||||
$this->session = $session->getSegment(SESSION_SEGMENT);
|
||||
|
||||
// Set a 'previous' flash value for better redirects
|
||||
$server_params = $this->request->getServerParams();
|
||||
if (array_key_exists('HTTP_REFERER', $server_params))
|
||||
$serverParams = $this->request->getServerParams();
|
||||
if (array_key_exists('HTTP_REFERER', $serverParams))
|
||||
{
|
||||
$this->session->setFlash('previous', $server_params['HTTP_REFERER']);
|
||||
$this->session->setFlash('previous', $serverParams['HTTP_REFERER']);
|
||||
}
|
||||
|
||||
// Set a message box if available
|
||||
@ -124,8 +124,8 @@ class Controller {
|
||||
*/
|
||||
public function redirectToDefaultRoute()
|
||||
{
|
||||
$default_type = $this->config->get(['routes', 'route_config', 'default_list']);
|
||||
$this->redirect($this->urlGenerator->defaultUrl($default_type), 303);
|
||||
$defaultType = $this->config->get(['routes', 'route_config', 'default_list']);
|
||||
$this->redirect($this->urlGenerator->defaultUrl($defaultType), 303);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -133,7 +133,7 @@ class Controller {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function redirect_to_previous()
|
||||
public function redirectToPrevious()
|
||||
{
|
||||
$previous = $this->session->getFlash('previous');
|
||||
$this->redirect($previous, 303);
|
||||
@ -145,31 +145,31 @@ class Controller {
|
||||
* @param string|null $url
|
||||
* @return void
|
||||
*/
|
||||
public function set_session_redirect($url = NULL)
|
||||
public function setSessionRedirect($url = NULL)
|
||||
{
|
||||
$server_params = $this->request->getServerParams();
|
||||
$serverParams = $this->request->getServerParams();
|
||||
|
||||
if ( ! array_key_exists('HTTP_REFERER', $server_params))
|
||||
if ( ! array_key_exists('HTTP_REFERER', $serverParams))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$util = $this->container->get('util');
|
||||
$double_form_page = $server_params['HTTP_REFERER'] === $this->request->getUri();
|
||||
$doubleFormPage = $serverParams['HTTP_REFERER'] === $this->request->getUri();
|
||||
|
||||
// Don't attempt to set the redirect url if
|
||||
// the page is one of the form type pages,
|
||||
// and the previous page is also a form type page_segments
|
||||
if ($double_form_page)
|
||||
if ($doubleFormPage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_null($url))
|
||||
{
|
||||
$url = $util->is_view_page()
|
||||
$url = $util->isViewPage()
|
||||
? $this->request->url->get()
|
||||
: $server_params['HTTP_REFERER'];
|
||||
: $serverParams['HTTP_REFERER'];
|
||||
}
|
||||
|
||||
$this->session->set('redirect_url', $url);
|
||||
@ -180,7 +180,7 @@ class Controller {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function session_redirect()
|
||||
public function sessionRedirect()
|
||||
{
|
||||
$target = $this->session->get('redirect_url');
|
||||
if (empty($target))
|
||||
@ -221,7 +221,7 @@ class Controller {
|
||||
* @throws InvalidArgumentException
|
||||
* @return string
|
||||
*/
|
||||
protected function load_partial($view, $template, array $data = [])
|
||||
protected function loadPartial($view, $template, array $data = [])
|
||||
{
|
||||
$router = $this->container->get('dispatcher');
|
||||
|
||||
@ -234,14 +234,14 @@ class Controller {
|
||||
$data['route_path'] = $route ? $router->getRoute()->path : '';
|
||||
|
||||
|
||||
$template_path = _dir($this->config->get('view_path'), "{$template}.php");
|
||||
$templatePath = _dir($this->config->get('view_path'), "{$template}.php");
|
||||
|
||||
if ( ! is_file($template_path))
|
||||
if ( ! is_file($templatePath))
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid template : {$template}");
|
||||
}
|
||||
|
||||
return $view->renderTemplate($template_path, (array)$data);
|
||||
return $view->renderTemplate($templatePath, (array)$data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,17 +252,17 @@ class Controller {
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
protected function render_full_page($view, $template, array $data)
|
||||
protected function renderFullPage($view, $template, array $data)
|
||||
{
|
||||
$view->appendOutput($this->load_partial($view, 'header', $data));
|
||||
$view->appendOutput($this->loadPartial($view, 'header', $data));
|
||||
|
||||
if (array_key_exists('message', $data) && is_array($data['message']))
|
||||
{
|
||||
$view->appendOutput($this->load_partial($view, 'message', $data['message']));
|
||||
$view->appendOutput($this->loadPartial($view, 'message', $data['message']));
|
||||
}
|
||||
|
||||
$view->appendOutput($this->load_partial($view, $template, $data));
|
||||
$view->appendOutput($this->load_partial($view, 'footer', $data));
|
||||
$view->appendOutput($this->loadPartial($view, $template, $data));
|
||||
$view->appendOutput($this->loadPartial($view, 'footer', $data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -280,11 +280,11 @@ class Controller {
|
||||
|
||||
if ($status !== '')
|
||||
{
|
||||
$message = $this->show_message($view, 'error', $status);
|
||||
$message = $this->showMessage($view, 'error', $status);
|
||||
}
|
||||
|
||||
// Set the redirect url
|
||||
$this->set_session_redirect();
|
||||
$this->setSessionRedirect();
|
||||
|
||||
$this->outputHTML('login', [
|
||||
'title' => 'Api login',
|
||||
@ -303,10 +303,10 @@ class Controller {
|
||||
$post = $this->request->getParsedBody();
|
||||
if ($auth->authenticate($post['password']))
|
||||
{
|
||||
return $this->session_redirect();
|
||||
return $this->sessionRedirect();
|
||||
}
|
||||
|
||||
$this->set_flash_message('Invalid username or password.');
|
||||
$this->setFlashMessage('Invalid username or password.');
|
||||
$this->redirect($this->urlGenerator->url('login'), 303);
|
||||
}
|
||||
|
||||
@ -361,12 +361,21 @@ class Controller {
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
public function set_flash_message($message, $type = "info")
|
||||
public function setFlashMessage($message, $type = "info")
|
||||
{
|
||||
$this->session->setFlash('message', [
|
||||
static $messages;
|
||||
|
||||
if (!$messages)
|
||||
{
|
||||
$messages = [];
|
||||
}
|
||||
|
||||
$messages[] = [
|
||||
'message_type' => $type,
|
||||
'message' => $message
|
||||
]);
|
||||
];
|
||||
|
||||
$this->session->setFlash('message', $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -393,7 +402,7 @@ class Controller {
|
||||
*/
|
||||
protected function showMessage($view, $type, $message)
|
||||
{
|
||||
return $this->load_partial($view, 'message', [
|
||||
return $this->loadPartial($view, 'message', [
|
||||
'message_type' => $type,
|
||||
'message' => $message
|
||||
]);
|
||||
@ -416,7 +425,7 @@ class Controller {
|
||||
}
|
||||
|
||||
$view->setStatusCode($code);
|
||||
$this->render_full_page($view, $template, $data);
|
||||
$this->renderFullPage($view, $template, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,7 +132,7 @@ class Anime extends BaseController {
|
||||
AnimeWatchingStatus::COMPLETED => 'Completed'
|
||||
];
|
||||
|
||||
$this->set_session_redirect();
|
||||
$this->setSessionRedirect();
|
||||
$this->outputHTML('anime/add', [
|
||||
'title' => $this->config->get('whose_list') .
|
||||
"'s Anime List · Add",
|
||||
@ -166,7 +166,7 @@ class Anime extends BaseController {
|
||||
$this->set_flash_message('Failed to add new anime to list', 'error');
|
||||
}
|
||||
|
||||
$this->session_redirect();
|
||||
$this->sessionRedirect();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,7 +191,7 @@ class Anime extends BaseController {
|
||||
->titleize();
|
||||
}
|
||||
|
||||
$this->set_session_redirect();
|
||||
$this->setSessionRedirect();
|
||||
|
||||
$this->outputHTML('anime/edit', [
|
||||
'title' => $this->config->get('whose_list') .
|
||||
@ -240,7 +240,7 @@ class Anime extends BaseController {
|
||||
$this->set_flash_message('Failed to update anime.', 'error');
|
||||
}
|
||||
|
||||
$this->session_redirect();
|
||||
$this->sessionRedirect();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -285,7 +285,7 @@ class Anime extends BaseController {
|
||||
$this->set_flash_message('Failed to delete anime.', 'error');
|
||||
}
|
||||
|
||||
$this->session_redirect();
|
||||
$this->sessionRedirect();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,7 +115,7 @@ class Collection extends BaseController {
|
||||
*/
|
||||
public function form($id = NULL)
|
||||
{
|
||||
$this->set_session_redirect();
|
||||
$this->setSessionRedirect();
|
||||
|
||||
$action = (is_null($id)) ? "Add" : "Edit";
|
||||
|
||||
@ -146,7 +146,7 @@ class Collection extends BaseController {
|
||||
$this->set_flash_message('Failed to update collection item', 'error');
|
||||
}
|
||||
|
||||
$this->session_redirect();
|
||||
$this->sessionRedirect();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,7 +167,7 @@ class Collection extends BaseController {
|
||||
$this->set_flash_message('Failed to add collection item.', 'error');
|
||||
}
|
||||
|
||||
$this->session_redirect();
|
||||
$this->sessionRedirect();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,7 +115,7 @@ class Manga extends Controller {
|
||||
->titleize();
|
||||
}
|
||||
|
||||
$this->set_session_redirect();
|
||||
$this->setSessionRedirect();
|
||||
$this->outputHTML('manga/add', [
|
||||
'title' => $this->config->get('whose_list') .
|
||||
"'s Manga List · Add",
|
||||
@ -149,7 +149,7 @@ class Manga extends Controller {
|
||||
$this->set_flash_message('Failed to add new manga to list' . $result['body'], 'error');
|
||||
}
|
||||
|
||||
$this->session_redirect();
|
||||
$this->sessionRedirect();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,7 +161,7 @@ class Manga extends Controller {
|
||||
*/
|
||||
public function edit($id, $status = "All")
|
||||
{
|
||||
$this->set_session_redirect();
|
||||
$this->setSessionRedirect();
|
||||
$item = $this->model->getLibraryItem($id);
|
||||
$title = $this->config->get('whose_list') . "'s Manga List · Edit";
|
||||
|
||||
@ -211,7 +211,7 @@ class Manga extends Controller {
|
||||
|
||||
}
|
||||
|
||||
$this->session_redirect();
|
||||
$this->sessionRedirect();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -257,7 +257,7 @@ class Manga extends Controller {
|
||||
$this->set_flash_message('Failed to delete manga.', 'error');
|
||||
}
|
||||
|
||||
$this->session_redirect();
|
||||
$this->sessionRedirect();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,9 +52,9 @@ class Dispatcher extends RoutingBase {
|
||||
|
||||
/**
|
||||
* Routes added to router
|
||||
* @var array $output_routes
|
||||
* @var array $outputRoutes
|
||||
*/
|
||||
protected $output_routes;
|
||||
protected $outputRoutes;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -68,7 +68,7 @@ class Dispatcher extends RoutingBase {
|
||||
$this->matcher = $container->get('aura-router')->getMatcher();
|
||||
$this->request = $container->get('request');
|
||||
|
||||
$this->output_routes = $this->_setupRoutes();
|
||||
$this->outputRoutes = $this->setupRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,12 +80,12 @@ class Dispatcher extends RoutingBase {
|
||||
{
|
||||
$logger = $this->container->getLogger('default');
|
||||
|
||||
$raw_route = $this->request->getUri()->getPath();
|
||||
$route_path = "/" . trim($raw_route, '/');
|
||||
$rawRoute = $this->request->getUri()->getPath();
|
||||
$routePath = "/" . trim($rawRoute, '/');
|
||||
|
||||
$logger->info('Dispatcher - Routing data from get_route method');
|
||||
$logger->info(print_r([
|
||||
'route_path' => $route_path
|
||||
'route_path' => $routePath
|
||||
], TRUE));
|
||||
|
||||
return $this->matcher->match($this->request);
|
||||
@ -98,7 +98,7 @@ class Dispatcher extends RoutingBase {
|
||||
*/
|
||||
public function getOutputRoutes()
|
||||
{
|
||||
return $this->output_routes;
|
||||
return $this->outputRoutes;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,10 +131,10 @@ class Dispatcher extends RoutingBase {
|
||||
{
|
||||
// If not route was matched, return an appropriate http
|
||||
// error message
|
||||
$error_route = $this->getErrorParams();
|
||||
$errorRoute = $this->getErrorParams();
|
||||
$controllerName = DEFAULT_CONTROLLER;
|
||||
$actionMethod = $error_route['action_method'];
|
||||
$params = $error_route['params'];
|
||||
$actionMethod = $errorRoute['action_method'];
|
||||
$params = $errorRoute['params'];
|
||||
}
|
||||
|
||||
$this->call($controllerName, $actionMethod, $params);
|
||||
@ -152,7 +152,7 @@ class Dispatcher extends RoutingBase {
|
||||
{
|
||||
if (array_key_exists('controller', $route->attributes))
|
||||
{
|
||||
$controller_name = $route->attributes['controller'];
|
||||
$controllerName = $route->attributes['controller'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -160,13 +160,13 @@ class Dispatcher extends RoutingBase {
|
||||
}
|
||||
|
||||
// Get the full namespace for a controller if a short name is given
|
||||
if (strpos($controller_name, '\\') === FALSE)
|
||||
if (strpos($controllerName, '\\') === FALSE)
|
||||
{
|
||||
$map = $this->getControllerList();
|
||||
$controller_name = $map[$controller_name];
|
||||
$controllerName = $map[$controllerName];
|
||||
}
|
||||
|
||||
$action_method = (array_key_exists('action', $route->attributes))
|
||||
$actionMethod = (array_key_exists('action', $route->attributes))
|
||||
? $route->attributes['action']
|
||||
: NOT_FOUND_METHOD;
|
||||
|
||||
@ -186,8 +186,8 @@ class Dispatcher extends RoutingBase {
|
||||
$logger->info(json_encode($params));
|
||||
|
||||
return [
|
||||
'controller_name' => $controller_name,
|
||||
'action_method' => $action_method,
|
||||
'controller_name' => $controllerName,
|
||||
'action_method' => $actionMethod,
|
||||
'params' => $params
|
||||
];
|
||||
}
|
||||
@ -199,16 +199,16 @@ class Dispatcher extends RoutingBase {
|
||||
*/
|
||||
public function getController()
|
||||
{
|
||||
$route_type = $this->__get('default_list');
|
||||
$request_uri = $this->request->getUri()->getPath();
|
||||
$path = trim($request_uri, '/');
|
||||
$routeType = $this->__get('default_list');
|
||||
$requestUri = $this->request->getUri()->getPath();
|
||||
$path = trim($requestUri, '/');
|
||||
|
||||
$segments = explode('/', $path);
|
||||
$controller = reset($segments);
|
||||
|
||||
if (empty($controller))
|
||||
{
|
||||
$controller = $route_type;
|
||||
$controller = $routeType;
|
||||
}
|
||||
|
||||
return $controller;
|
||||
@ -221,22 +221,22 @@ class Dispatcher extends RoutingBase {
|
||||
*/
|
||||
public function getControllerList()
|
||||
{
|
||||
$default_namespace = DEFAULT_CONTROLLER_NAMESPACE;
|
||||
$path = str_replace('\\', '/', $default_namespace);
|
||||
$defaultNamespace = DEFAULT_CONTROLLER_NAMESPACE;
|
||||
$path = str_replace('\\', '/', $defaultNamespace);
|
||||
$path = str_replace('Aviat/AnimeClient/', '', $path);
|
||||
$path = trim($path, '/');
|
||||
$actual_path = realpath(_dir(SRC_DIR, $path));
|
||||
$class_files = glob("{$actual_path}/*.php");
|
||||
$actualPath = realpath(_dir(SRC_DIR, $path));
|
||||
$classFiles = glob("{$actualPath}/*.php");
|
||||
|
||||
$controllers = [];
|
||||
|
||||
foreach ($class_files as $file)
|
||||
foreach ($classFiles as $file)
|
||||
{
|
||||
$raw_class_name = basename(str_replace(".php", "", $file));
|
||||
$path = strtolower(basename($raw_class_name));
|
||||
$class_name = trim($default_namespace . '\\' . $raw_class_name, '\\');
|
||||
$rawClassName = basename(str_replace(".php", "", $file));
|
||||
$path = strtolower(basename($rawClassName));
|
||||
$className = trim($defaultNamespace . '\\' . $rawClassName, '\\');
|
||||
|
||||
$controllers[$path] = $class_name;
|
||||
$controllers[$path] = $className;
|
||||
}
|
||||
|
||||
return $controllers;
|
||||
@ -260,6 +260,7 @@ class Dispatcher extends RoutingBase {
|
||||
// Run the appropriate controller method
|
||||
$logger->debug('Dispatcher - controller arguments');
|
||||
$logger->debug(print_r($params, TRUE));
|
||||
|
||||
call_user_func_array([$controller, $method], $params);
|
||||
}
|
||||
|
||||
@ -277,7 +278,7 @@ class Dispatcher extends RoutingBase {
|
||||
$logger->info('Dispatcher - failed route');
|
||||
$logger->info(print_r($failure, TRUE));
|
||||
|
||||
$action_method = ERROR_MESSAGE_METHOD;
|
||||
$actionMethod = ERROR_MESSAGE_METHOD;
|
||||
|
||||
$params = [];
|
||||
|
||||
@ -300,13 +301,13 @@ class Dispatcher extends RoutingBase {
|
||||
|
||||
default:
|
||||
// Fall back to a 404 message
|
||||
$action_method = NOT_FOUND_METHOD;
|
||||
$actionMethod = NOT_FOUND_METHOD;
|
||||
break;
|
||||
}
|
||||
|
||||
return [
|
||||
'params' => $params,
|
||||
'action_method' => $action_method
|
||||
'action_method' => $actionMethod
|
||||
];
|
||||
}
|
||||
|
||||
@ -315,9 +316,9 @@ class Dispatcher extends RoutingBase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _setupRoutes()
|
||||
protected function setupRoutes()
|
||||
{
|
||||
$route_type = $this->getController();
|
||||
$routeType = $this->getController();
|
||||
|
||||
// Add routes
|
||||
$routes = [];
|
||||
@ -326,18 +327,18 @@ class Dispatcher extends RoutingBase {
|
||||
$path = $route['path'];
|
||||
unset($route['path']);
|
||||
|
||||
$controller_map = $this->getControllerList();
|
||||
$controller_class = (array_key_exists($route_type, $controller_map))
|
||||
? $controller_map[$route_type]
|
||||
$controllerMap = $this->getControllerList();
|
||||
$controllerClass = (array_key_exists($routeType, $controllerMap))
|
||||
? $controllerMap[$routeType]
|
||||
: DEFAULT_CONTROLLER;
|
||||
|
||||
if (array_key_exists($route_type, $controller_map))
|
||||
if (array_key_exists($routeType, $controllerMap))
|
||||
{
|
||||
$controller_class = $controller_map[$route_type];
|
||||
$controllerClass = $controllerMap[$routeType];
|
||||
}
|
||||
|
||||
// Prepend the controller to the route parameters
|
||||
$route['controller'] = $controller_class;
|
||||
$route['controller'] = $controllerClass;
|
||||
|
||||
// Select the appropriate router method based on the http verb
|
||||
$add = (array_key_exists('verb', $route))
|
||||
|
@ -62,7 +62,7 @@ class MenuGenerator extends UrlGenerator {
|
||||
* @param array $menus
|
||||
* @return array
|
||||
*/
|
||||
protected function parse_config(array $menus)
|
||||
protected function parseConfig(array $menus)
|
||||
{
|
||||
$parsed = [];
|
||||
|
||||
@ -88,17 +88,17 @@ class MenuGenerator extends UrlGenerator {
|
||||
public function generate($menu)
|
||||
{
|
||||
$menus = $this->config->get('menus');
|
||||
$parsed_config = $this->parse_config($menus);
|
||||
$parsedConfig = $this->parseConfig($menus);
|
||||
|
||||
// Bail out early on invalid menu
|
||||
if ( ! $this->arr($parsed_config)->hasKey($menu))
|
||||
if ( ! $this->arr($parsedConfig)->hasKey($menu))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$menu_config = $parsed_config[$menu];
|
||||
$menuConfig = $parsedConfig[$menu];
|
||||
|
||||
foreach ($menu_config as $title => $path)
|
||||
foreach ($menuConfig as $title => $path)
|
||||
{
|
||||
$has = $this->string($this->path())->contains($path);
|
||||
$selected = ($has && strlen($this->path()) >= strlen($path));
|
||||
|
16
src/Util.php
16
src/Util.php
@ -31,7 +31,7 @@ class Util {
|
||||
* Routes that don't require a second navigation level
|
||||
* @var array
|
||||
*/
|
||||
private static $form_pages = [
|
||||
private static $formPages = [
|
||||
'edit',
|
||||
'add',
|
||||
'update',
|
||||
@ -65,7 +65,7 @@ class Util {
|
||||
* @param string $b - Second item to compare
|
||||
* @return string
|
||||
*/
|
||||
public static function is_selected($a, $b)
|
||||
public static function isSelected($a, $b)
|
||||
{
|
||||
return ($a === $b) ? 'selected' : '';
|
||||
}
|
||||
@ -77,7 +77,7 @@ class Util {
|
||||
* @param string $b - Second item to compare
|
||||
* @return string
|
||||
*/
|
||||
public static function is_not_selected($a, $b)
|
||||
public static function isNotSelected($a, $b)
|
||||
{
|
||||
return ($a !== $b) ? 'selected' : '';
|
||||
}
|
||||
@ -87,13 +87,13 @@ class Util {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_view_page()
|
||||
public function isViewPage()
|
||||
{
|
||||
$url = $this->container->get('request')
|
||||
->getUri();
|
||||
$page_segments = explode("/", (string) $url);
|
||||
$pageSegments = explode("/", (string) $url);
|
||||
|
||||
$intersect = array_intersect($page_segments, self::$form_pages);
|
||||
$intersect = array_intersect($pageSegments, self::$formPages);
|
||||
|
||||
return empty($intersect);
|
||||
}
|
||||
@ -104,9 +104,9 @@ class Util {
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_form_page()
|
||||
public function isFormPage()
|
||||
{
|
||||
return ! $this->is_view_page();
|
||||
return ! $this->isViewPage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ class MenuGeneratorTest extends AnimeClientTestCase {
|
||||
'All' => '/anime/all'
|
||||
]
|
||||
];
|
||||
$this->assertEquals($expected, $friend->parse_config($menus));
|
||||
$this->assertEquals($expected, $friend->parseConfig($menus));
|
||||
}
|
||||
|
||||
public function testBadConfig()
|
||||
|
@ -29,19 +29,19 @@ class UtilTest extends AnimeClientTestCase {
|
||||
public function testIsSelected()
|
||||
{
|
||||
// Failure to match
|
||||
$this->assertEquals('', Util::is_selected('foo', 'bar'));
|
||||
$this->assertEquals('', Util::isSelected('foo', 'bar'));
|
||||
|
||||
// Matches
|
||||
$this->assertEquals('selected', Util::is_selected('foo', 'foo'));
|
||||
$this->assertEquals('selected', Util::isSelected('foo', 'foo'));
|
||||
}
|
||||
|
||||
public function testIsNotSelected()
|
||||
{
|
||||
// Failure to match
|
||||
$this->assertEquals('selected', Util::is_not_selected('foo', 'bar'));
|
||||
$this->assertEquals('selected', Util::isNotSelected('foo', 'bar'));
|
||||
|
||||
// Matches
|
||||
$this->assertEquals('', Util::is_not_selected('foo', 'foo'));
|
||||
$this->assertEquals('', Util::isNotSelected('foo', 'foo'));
|
||||
}
|
||||
|
||||
public function dataIsViewPage()
|
||||
@ -76,7 +76,7 @@ class UtilTest extends AnimeClientTestCase {
|
||||
'REQUEST_URI' => $uri
|
||||
]
|
||||
]);
|
||||
$this->assertEquals($expected, $this->util->is_view_page());
|
||||
$this->assertEquals($expected, $this->util->isViewPage());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,6 +89,6 @@ class UtilTest extends AnimeClientTestCase {
|
||||
'REQUEST_URI' => $uri
|
||||
]
|
||||
]);
|
||||
$this->assertEquals(!$expected, $this->util->is_form_page());
|
||||
$this->assertEquals(!$expected, $this->util->isFormPage());
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
"meta": {
|
||||
"name": "Crunchyroll",
|
||||
"link": true,
|
||||
"logo": "<svg class=\"streaming-logo\" viewBox=\"0 0 50 50\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><g fill=\"#F78B24\" fill-rule=\"evenodd\"><path d=\"M22.549 49.145c-.815-.077-2.958-.456-3.753-.663-6.873-1.79-12.693-6.59-15.773-13.009C1.335 31.954.631 28.807.633 24.788c.003-4.025.718-7.235 2.38-10.686 1.243-2.584 2.674-4.609 4.706-6.66 3.8-3.834 8.614-6.208 14.067-6.936 1.783-.239 5.556-.161 7.221.148 3.463.642 6.571 1.904 9.357 3.797 5.788 3.934 9.542 9.951 10.52 16.861.21 1.48.332 4.559.19 4.816-.077.14-.117-.007-.167-.615-.25-3.015-1.528-6.66-3.292-9.388C40.253 7.836 30.249 4.32 20.987 7.467c-7.15 2.43-12.522 8.596-13.997 16.06-.73 3.692-.51 7.31.658 10.882a21.426 21.426 0 0 0 13.247 13.518c1.475.515 3.369.944 4.618 1.047 1.496.122 1.119.239-.727.224-1.006-.008-2.013-.032-2.237-.053z\"><\/path><path d=\"M27.685 46.1c-7.731-.575-14.137-6.455-15.474-14.204-.243-1.41-.29-4.047-.095-5.345 1.16-7.706 6.97-13.552 14.552-14.639 1.537-.22 4.275-.143 5.746.162 1.28.266 2.7.737 3.814 1.266l.865.411-.814.392c-2.936 1.414-4.748 4.723-4.323 7.892.426 3.173 2.578 5.664 5.667 6.56 1.112.322 2.812.322 3.925 0 1.438-.417 2.566-1.1 3.593-2.173.346-.362.652-.621.68-.576.027.046.106.545.176 1.11.171 1.395.07 4.047-.204 5.371-.876 4.218-3.08 7.758-6.463 10.374-3.2 2.476-7.434 3.711-11.645 3.399z\"><\/path><\/g><\/svg>"
|
||||
"image": "streaming-logos\/crunchyroll.svg"
|
||||
},
|
||||
"link": "http:\/\/www.crunchyroll.com\/attack-on-titan",
|
||||
"subs": ["en"],
|
||||
@ -24,7 +24,7 @@
|
||||
"meta": {
|
||||
"name": "Hulu",
|
||||
"link": true,
|
||||
"logo": "<svg class=\"streaming-logo\" viewBox=\"0 0 34 50\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M22.222 13.889h-11.11V0H0v50h11.111V27.778c0-1.39 1.111-2.778 2.778-2.778h5.555c1.39 0 2.778 1.111 2.778 2.778V50h11.111V25c0-6.111-5-11.111-11.11-11.111z\" fill=\"#8BC34A\" fill-rule=\"evenodd\"><\/path><\/svg>"
|
||||
"image": "streaming-logos\/hulu.svg"
|
||||
},
|
||||
"link": "http:\/\/www.hulu.com\/attack-on-titan",
|
||||
"subs": ["en"],
|
||||
@ -33,7 +33,7 @@
|
||||
"meta": {
|
||||
"name": "Funimation",
|
||||
"link": true,
|
||||
"logo": "<svg class=\"streaming-logo\" viewBox=\"0 0 50 50\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M24.066.017a24.922 24.922 0 0 1 13.302 3.286 25.098 25.098 0 0 1 7.833 7.058 24.862 24.862 0 0 1 4.207 9.575c.82 4.001.641 8.201-.518 12.117a24.946 24.946 0 0 1-4.868 9.009 24.98 24.98 0 0 1-7.704 6.118 24.727 24.727 0 0 1-10.552 2.718A24.82 24.82 0 0 1 13.833 47.3c-5.815-2.872-10.408-8.107-12.49-14.25-2.162-6.257-1.698-13.375 1.303-19.28C5.483 8.07 10.594 3.55 16.602 1.435A24.94 24.94 0 0 1 24.066.017zm-8.415 33.31c.464 2.284 1.939 4.358 3.99 5.48 2.174 1.217 4.765 1.444 7.202 1.181 2.002-.217 3.986-.992 5.455-2.397 1.173-1.151 2.017-2.648 2.33-4.267-1.189-.027-2.378 0-3.566-.03-.568.082-1.137-.048-1.705.014-1.232.012-2.465.003-3.697-.01-.655.066-1.309-.035-1.963.013-1.166-.053-2.334.043-3.5-.025-1.515.08-3.03-.035-4.546.042z\" fill=\"#411299\" fill-rule=\"evenodd\"><\/path><\/svg>"
|
||||
"image": "streaming-logos\/funimation.svg"
|
||||
},
|
||||
"link": "http:\/\/www.funimation.com\/shows\/attack-on-titan\/videos\/episodes",
|
||||
"subs": ["en"],
|
||||
@ -42,7 +42,7 @@
|
||||
"meta": {
|
||||
"name": "Netflix",
|
||||
"link": false,
|
||||
"logo": "<svg class=\"streaming-logo\" viewBox=\"0 0 26 50\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M.057.258C2.518.253 4.982.263 7.446.253c2.858 7.76 5.621 15.556 8.456 23.324.523 1.441 1.003 2.897 1.59 4.312.078-9.209.01-18.42.034-27.631h7.763v46.36c-2.812.372-5.637.627-8.457.957-1.203-3.451-2.396-6.902-3.613-10.348-1.796-5.145-3.557-10.302-5.402-15.428.129 8.954.015 17.912.057 26.871-2.603.39-5.227.637-7.815 1.119C.052 33.279.06 16.768.057.258z\" fill=\"#E21221\" fill-rule=\"evenodd\"><\/path><\/svg>"
|
||||
"image": "streaming-logos\/netflix.svg"
|
||||
},
|
||||
"link": "t",
|
||||
"subs": ["en"],
|
||||
|
Loading…
Reference in New Issue
Block a user