2020-07-15 21:05:41 +00:00
|
|
|
<?php
|
|
|
|
|
2020-10-20 21:29:50 +00:00
|
|
|
namespace Alltube\Factory;
|
2020-07-15 21:05:41 +00:00
|
|
|
|
|
|
|
use Alltube\Exception\DependencyException;
|
2020-10-20 21:29:50 +00:00
|
|
|
use Alltube\LocaleManager;
|
2020-10-21 20:47:15 +00:00
|
|
|
use Slim\Container;
|
2020-07-15 21:05:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class LocaleManagerFactory
|
|
|
|
* @package Alltube
|
|
|
|
*/
|
|
|
|
class LocaleManagerFactory
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2020-10-21 20:47:15 +00:00
|
|
|
* @param Container $container
|
2020-07-15 21:05:41 +00:00
|
|
|
* @return LocaleManager|null
|
|
|
|
* @throws DependencyException
|
|
|
|
*/
|
2020-10-21 20:47:15 +00:00
|
|
|
public static function create(Container $container)
|
2020-07-15 21:05:41 +00:00
|
|
|
{
|
|
|
|
if (!class_exists('Locale')) {
|
|
|
|
throw new DependencyException('You need to install the intl extension for PHP.');
|
|
|
|
}
|
|
|
|
|
2020-10-21 20:47:15 +00:00
|
|
|
return new LocaleManager($container->get('session'));
|
2020-07-15 21:05:41 +00:00
|
|
|
}
|
|
|
|
}
|