Convert SessionManager to a factory class
This commit is contained in:
parent
5b0ee7651b
commit
de8c5e5dc7
10 changed files with 64 additions and 52 deletions
|
@ -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'));
|
||||
}
|
||||
}
|
||||
|
|
27
classes/Factory/SessionFactory.php
Normal file
27
classes/Factory/SessionFactory.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* SessionFactory class.
|
||||
*/
|
||||
|
||||
namespace Alltube\Factory;
|
||||
|
||||
use Aura\Session\Session;
|
||||
|
||||
/**
|
||||
* Manage sessions.
|
||||
*/
|
||||
class SessionFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the current session.
|
||||
*
|
||||
* @return Session
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
$session_factory = new \Aura\Session\SessionFactory();
|
||||
return $session_factory->newInstance($_COOKIE);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue