Use a factory to Config and LocaleManager (see #298)
This commit is contained in:
parent
96a75cbf14
commit
280618bb6b
9 changed files with 145 additions and 87 deletions
40
classes/ConfigFactory.php
Normal file
40
classes/ConfigFactory.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Alltube;
|
||||
|
||||
use Symfony\Component\ErrorHandler\Debug;
|
||||
|
||||
/**
|
||||
* Class ConfigFactory
|
||||
* @package Alltube
|
||||
*/
|
||||
class ConfigFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* @return Config
|
||||
* @throws Exception\ConfigException
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
$configPath = __DIR__ . '/../config/config.yml';
|
||||
if (is_file($configPath)) {
|
||||
Config::setFile($configPath);
|
||||
}
|
||||
|
||||
$config = Config::getInstance();
|
||||
if ($config->uglyUrls) {
|
||||
$container['router'] = new UglyRouter();
|
||||
}
|
||||
if ($config->debug) {
|
||||
/*
|
||||
We want to enable this as soon as possible,
|
||||
in order to catch errors that are thrown
|
||||
before the Slim error handler is ready.
|
||||
*/
|
||||
Debug::enable();
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue