Refactored Config.

This commit is contained in:
Dmitry Khomutov 2018-03-04 15:56:02 +07:00
parent e23ad3237a
commit dd9f43b7dd
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
37 changed files with 40 additions and 43 deletions

View file

@ -32,7 +32,7 @@ $conf['b8']['app']['namespace'] = 'PHPCensor';
$conf['b8']['app']['default_controller'] = 'Home';
$conf['b8']['view']['path'] = SRC_DIR . 'View/';
$config = new b8\Config($conf);
$config = new PHPCensor\Config($conf);
$configFile = APP_DIR . 'config.yml';
if (file_exists($configFile)) {

View file

@ -6,6 +6,7 @@ use b8\Exception\HttpException\NotFoundException;
use b8\Http\Response;
use b8\Http\Request;
use b8\Http\Router;
use PHPCensor\Config;
class Application
{

View file

@ -5,6 +5,7 @@ namespace b8;
use b8\Http\Request;
use b8\Http\Response;
use PHPCensor\View;
use PHPCensor\Config;
abstract class Controller
{

View file

@ -3,7 +3,7 @@
namespace b8\Form;
use PHPCensor\View;
use b8\Config;
use PHPCensor\Config;
abstract class Element
{

View file

@ -3,7 +3,7 @@
namespace b8\Http;
use b8\Application;
use b8\Config;
use PHPCensor\Config;
class Router
{

View file

@ -151,7 +151,7 @@ class Application extends b8\Application
*/
protected function shouldSkipAuth()
{
$config = b8\Config::getInstance();
$config = Config::getInstance();
$disableAuth = (bool)$config->get('php-censor.security.disable_auth', false);
$defaultUserId = (integer)$config->get('php-censor.security.default_user_id', 1);

View file

@ -7,7 +7,6 @@ use PHPCensor\Helper\MailerFactory;
use PHPCensor\Logging\BuildLogger;
use PHPCensor\Model\Build;
use PHPCensor\Store\Factory;
use b8\Config;
use PHPCensor\Store\BuildErrorWriter;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerInterface;

View file

@ -5,7 +5,7 @@ namespace PHPCensor\Command;
use Exception;
use PDO;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Store\Factory;
use PHPCensor\Model\ProjectGroup;
use PHPCensor\Store\UserStore;

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Command;
use b8\Config;
use PHPCensor\Config;
use Monolog\Logger;
use PHPCensor\Logging\BuildDBLogHandler;
use PHPCensor\Logging\LoggedBuildContextTidier;

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Command;
use b8\Config;
use PHPCensor\Config;
use Monolog\Logger;
use PHPCensor\Logging\OutputLogHandler;
use PHPCensor\Worker\BuildWorker;

View file

@ -1,11 +1,11 @@
<?php
namespace b8;
namespace PHPCensor;
use Symfony\Component\Yaml\Parser as YamlParser;
if (!defined('B8_PATH')) {
define('B8_PATH', __DIR__ . '/');
define('B8_PATH', dirname(__DIR__) . '/B8Framework/');
}
class Config

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Console;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Store\Factory;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\StreamHandler;

View file

@ -2,7 +2,6 @@
namespace PHPCensor;
use b8\Config;
use b8\Exception\HttpException\ForbiddenException;
use b8\Http\Request;
use b8\Http\Response;

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Controller;
use b8;
use PHPCensor\Config;
use PHPCensor\Helper\Lang;
use PHPCensor\Controller;
@ -22,7 +22,7 @@ class HomeController extends Controller
'left' => [],
'right' => [],
];
$widgets_config = b8\Config::getInstance()->get('php-censor.dashboard_widgets', [
$widgets_config = Config::getInstance()->get('php-censor.dashboard_widgets', [
'all_projects' => [
'side' => 'left',
],

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Controller;
use b8;
use PHPCensor\Config;
use b8\Exception\HttpException\NotFoundException;
use b8\Form;
use PHPCensor\Controller;
@ -116,7 +116,7 @@ class UserController extends Controller
$language->setLabel(Lang::get('language'));
$language->setRequired(true);
$language->setOptions(array_merge(
[null => Lang::get('default') . ' (' . b8\Config::getInstance()->get('php-censor.language') . ')'],
[null => Lang::get('default') . ' (' . Config::getInstance()->get('php-censor.language') . ')'],
Lang::getLanguageOptions())
);
$language->setValue($user->getLanguage());
@ -128,7 +128,7 @@ class UserController extends Controller
$perPage->setLabel(Lang::get('per_page'));
$perPage->setRequired(true);
$perPage->setOptions([
null => Lang::get('default') . ' (' . b8\Config::getInstance()->get('php-censor.per_page') . ')',
null => Lang::get('default') . ' (' . Config::getInstance()->get('php-censor.per_page') . ')',
10 => 10,
25 => 25,
50 => 50,

View file

@ -12,7 +12,7 @@ use PHPCensor\Service\BuildService;
use PHPCensor\Store\BuildStore;
use PHPCensor\Store\ProjectStore;
use b8\Controller;
use b8\Config;
use PHPCensor\Config;
use b8\Exception\HttpException\NotFoundException;
use PHPCensor\Store\Factory;

View file

@ -2,8 +2,6 @@
namespace PHPCensor;
use b8\Config;
class Database extends \PDO
{
const MYSQL_TYPE = 'mysql';

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Helper;
use b8\Config;
use PHPCensor\Config;
use GuzzleHttp\Client;
/**

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Helper;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Builder;
/**
@ -99,13 +99,13 @@ class Email
'php-censor.email_settings.from_address',
self::DEFAULT_FROM
);
if (strpos($from, '<') === false) {
return (string)$from;
}
preg_match('#^(.*?)<(.*)>$#ui', $from, $fromParts);
return [$fromParts[2] => $fromParts[1]];
}

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Helper;
use b8\Config;
use PHPCensor\Config;
use GuzzleHttp\Client;
use Symfony\Component\Cache\Simple\FilesystemCache;

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Helper;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Store\Factory;
use PHPCensor\Store\UserStore;

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Helper;
use b8\Config;
use PHPCensor\Config;
/**
* Helper class for dealing with SSH keys.

View file

@ -6,7 +6,7 @@ use GuzzleHttp\Client;
use PHPCensor\Builder;
use PHPCensor\Helper\Bitbucket;
use PHPCensor\Helper\Diff;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Model\Build;
use PHPCensor\Model\BuildError;

View file

@ -6,7 +6,7 @@ use GuzzleHttp\Client;
use PHPCensor\Builder;
use PHPCensor\Helper\Diff;
use PHPCensor\Helper\Github;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Model\Build;
use PHPCensor\Model\BuildError;

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Model;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Model;
/**

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Security\Authentication;
use b8\Config;
use PHPCensor\Config;
/**
* Authentication facade.

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Service;
use b8\Config;
use PHPCensor\Config;
use Pheanstalk\Pheanstalk;
use Pheanstalk\PheanstalkInterface;
use PHPCensor\BuildFactory;

View file

@ -2,7 +2,7 @@
namespace PHPCensor\Store;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Database;
use PHPCensor\Model\BuildError;

View file

@ -2,7 +2,6 @@
namespace PHPCensor;
use b8\Config;
use PHPCensor\Store\Factory;
use PHPCensor\Model\User;
use PHPCensor\Store\UserStore;

View file

@ -3,7 +3,7 @@
namespace Tests\b8;
use b8\Form;
use b8\Config;
use PHPCensor\Config;
class FormTest extends \PHPUnit\Framework\TestCase
{

View file

@ -9,7 +9,7 @@ class WebhookControllerTest extends \PHPUnit\Framework\TestCase
public function test_wrong_action_name_return_json_with_error()
{
$webController = new WebhookController(
$this->prophesize('b8\Config')->reveal(),
$this->prophesize('PHPCensor\Config')->reveal(),
$this->prophesize('b8\Http\Request')->reveal(),
$this->prophesize('b8\Http\Response')->reveal()
);

View file

@ -2,7 +2,7 @@
namespace Tests\b8;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Database;
class DatabaseMysqlTest extends \PHPUnit_Extensions_Database_TestCase

View file

@ -2,7 +2,7 @@
namespace Tests\b8;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Database;
class DatabasePostgresqlTest extends \PHPUnit_Extensions_Database_TestCase

View file

@ -2,7 +2,7 @@
namespace Tests\PHPCensor\Plugin;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Plugin;
use PHPCensor\Plugin\Email as EmailPlugin;
use PHPCensor\Model\Build;

View file

@ -2,7 +2,7 @@
namespace Tests\PHPCensor;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Database;
use PHPCensor\Store\Factory;
use PHPCensor\Model\Project;

View file

@ -2,7 +2,7 @@
namespace Tests\PHPCensor;
use b8\Config;
use PHPCensor\Config;
use PHPCensor\Database;
use PHPCensor\Store\Factory;
use PHPCensor\Model\Project;

View file

@ -33,7 +33,7 @@ $conf['b8']['app']['default_controller'] = 'Home';
$conf['b8']['view']['path'] = SRC_DIR . 'View/';
$conf['php-censor']['url'] = 'http://php-censor.local';
$config = new b8\Config($conf);
$config = new PHPCensor\Config($conf);
if (!defined('APP_URL')) {
define('APP_URL', $config->get('php-censor.url', '') . '/');