Stop using a singleton for LocaleManager (#298)
This commit is contained in:
parent
f5045b3ae7
commit
15636aa435
7 changed files with 9 additions and 46 deletions
|
@ -10,7 +10,6 @@ use Alltube\Exception\ConfigException;
|
|||
use Alltube\Library\Downloader;
|
||||
use Jawira\CaseConverter\CaseConverterException;
|
||||
use Jean85\PrettyVersions;
|
||||
use PackageVersions\Versions;
|
||||
use Symfony\Component\ErrorHandler\Debug;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Jawira\CaseConverter\Convert;
|
||||
|
@ -159,7 +158,7 @@ class Config
|
|||
$this->applyOptions($options);
|
||||
$this->getEnv();
|
||||
$this->validateOptions();
|
||||
$localeManager = LocaleManager::getInstance();
|
||||
$localeManager = new LocaleManager();
|
||||
|
||||
if (empty($this->genericFormats)) {
|
||||
// We don't put this in the class definition so it can be detected by xgettext.
|
||||
|
|
|
@ -50,17 +50,10 @@ class LocaleManager
|
|||
*/
|
||||
private $translator;
|
||||
|
||||
/**
|
||||
* Singleton instance.
|
||||
*
|
||||
* @var LocaleManager|null
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* LocaleManager constructor.
|
||||
*/
|
||||
private function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
$session = SessionManager::getSession();
|
||||
$this->sessionSegment = $session->getSegment(self::class);
|
||||
|
@ -171,29 +164,4 @@ class LocaleManager
|
|||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LocaleManager singleton instance.
|
||||
*
|
||||
* @return LocaleManager
|
||||
* @todo Stop using a singleton.
|
||||
*/
|
||||
public static function getInstance()
|
||||
{
|
||||
if (!isset(self::$instance)) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy singleton instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function destroyInstance()
|
||||
{
|
||||
self::$instance = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,6 @@ class LocaleManagerFactory
|
|||
throw new DependencyException('You need to install the intl extension for PHP.');
|
||||
}
|
||||
|
||||
return LocaleManager::getInstance();
|
||||
return new LocaleManager();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue