Convert SessionManager to a factory class

This commit is contained in:
Pierre Rudloff 2020-10-21 22:47:15 +02:00
parent 5b0ee7651b
commit de8c5e5dc7
10 changed files with 64 additions and 52 deletions

View file

@ -4,6 +4,7 @@ namespace Alltube\Factory;
use Alltube\Exception\DependencyException;
use Alltube\LocaleManager;
use Slim\Container;
/**
* Class LocaleManagerFactory
@ -13,15 +14,16 @@ class LocaleManagerFactory
{
/**
* @param Container $container
* @return LocaleManager|null
* @throws DependencyException
*/
public static function create()
public static function create(Container $container)
{
if (!class_exists('Locale')) {
throw new DependencyException('You need to install the intl extension for PHP.');
}
return new LocaleManager();
return new LocaleManager($container->get('session'));
}
}