2016-10-20 22:09:36 -04:00
|
|
|
<?php declare(strict_types=1);
|
2015-11-16 19:30:04 -05:00
|
|
|
/**
|
2017-02-16 11:09:37 -05:00
|
|
|
* Hummingbird Anime List Client
|
2015-11-16 19:30:04 -05:00
|
|
|
*
|
2017-02-16 11:09:37 -05:00
|
|
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
2015-11-16 19:30:04 -05:00
|
|
|
*
|
2016-10-20 22:09:36 -04:00
|
|
|
* PHP version 7
|
2016-08-30 10:01:18 -04:00
|
|
|
*
|
2015-11-16 19:30:04 -05:00
|
|
|
* @package HummingbirdAnimeClient
|
2016-08-30 10:01:18 -04:00
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2017-02-16 11:09:37 -05:00
|
|
|
* @copyright 2015 - 2017 Timothy J. Warren
|
2016-08-30 10:01:18 -04:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2017-02-16 11:09:37 -05:00
|
|
|
* @version 4.0
|
2017-03-07 20:53:58 -05:00
|
|
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
2015-11-16 19:30:04 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Aviat\AnimeClient;
|
|
|
|
|
2016-02-10 17:30:45 -05:00
|
|
|
use Yosymfony\Toml\Toml;
|
|
|
|
|
2016-08-29 16:36:13 -04:00
|
|
|
define('SRC_DIR', realpath(__DIR__));
|
2016-01-06 17:06:30 -05:00
|
|
|
|
2017-02-08 15:48:20 -05:00
|
|
|
const SESSION_SEGMENT = 'Aviat\AnimeClient\Auth';
|
2017-03-31 13:37:53 -04:00
|
|
|
const DEFAULT_CONTROLLER = 'Aviat\AnimeClient\Controller\Index';
|
2017-02-08 15:48:20 -05:00
|
|
|
const DEFAULT_CONTROLLER_NAMESPACE = 'Aviat\AnimeClient\Controller';
|
2017-03-31 13:37:53 -04:00
|
|
|
const DEFAULT_LIST_CONTROLLER = 'Aviat\AnimeClient\Controller\Anime';
|
2017-02-08 15:48:20 -05:00
|
|
|
const DEFAULT_CONTROLLER_METHOD = 'index';
|
|
|
|
const NOT_FOUND_METHOD = 'notFound';
|
|
|
|
const ERROR_MESSAGE_METHOD = 'errorPage';
|
|
|
|
const SRC_DIR = SRC_DIR;
|
|
|
|
|
2016-01-06 15:44:40 -05:00
|
|
|
/**
|
2017-02-08 15:48:20 -05:00
|
|
|
* Load configuration options from .toml files
|
|
|
|
*
|
|
|
|
* @param string $path - Path to load config
|
|
|
|
* @return array
|
2016-01-06 15:44:40 -05:00
|
|
|
*/
|
2017-02-08 15:48:20 -05:00
|
|
|
function loadToml(string $path): array
|
|
|
|
{
|
|
|
|
$output = [];
|
|
|
|
$files = glob("{$path}/*.toml");
|
2016-01-04 10:53:03 -05:00
|
|
|
|
2017-02-08 15:48:20 -05:00
|
|
|
foreach ($files as $file)
|
2016-02-10 17:30:45 -05:00
|
|
|
{
|
2017-02-08 15:48:20 -05:00
|
|
|
$key = str_replace('.toml', '', basename($file));
|
|
|
|
$toml = file_get_contents($file);
|
|
|
|
$config = Toml::Parse($toml);
|
2016-02-10 17:30:45 -05:00
|
|
|
|
2017-02-08 15:48:20 -05:00
|
|
|
if ($key === 'config')
|
2016-02-10 17:30:45 -05:00
|
|
|
{
|
2017-02-08 15:48:20 -05:00
|
|
|
foreach($config as $name => $value)
|
2016-02-10 17:30:45 -05:00
|
|
|
{
|
2017-02-08 15:48:20 -05:00
|
|
|
$output[$name] = $value;
|
2016-02-10 17:30:45 -05:00
|
|
|
}
|
|
|
|
|
2017-02-08 15:48:20 -05:00
|
|
|
continue;
|
2016-02-10 17:30:45 -05:00
|
|
|
}
|
|
|
|
|
2017-02-08 15:48:20 -05:00
|
|
|
$output[$key] = $config;
|
2016-02-10 17:30:45 -05:00
|
|
|
}
|
2017-02-08 15:48:20 -05:00
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|