Files
Phraseanet/lib/Alchemy/Phrasea/Authentication/Provider/Factory.php
Benoît Burnichon 51023c5533 bump copyright year
2016-01-05 13:38:14 +01:00

44 lines
1.1 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Authentication\Provider;
use Alchemy\Phrasea\Exception\InvalidArgumentException;
use Symfony\Component\Routing\Generator\UrlGenerator;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
class Factory
{
private $generator;
private $session;
public function __construct(UrlGenerator $generator, SessionInterface $session)
{
$this->generator = $generator;
$this->session = $session;
}
public function build($name, array $options = [])
{
$name = implode('', array_map(function ($chunk) {
return ucfirst(strtolower($chunk));
}, explode('-', $name)));
$class_name = sprintf('%s\\%s', __NAMESPACE__, $name);
if (!class_exists($class_name)) {
throw new InvalidArgumentException(sprintf('Invalid provider %s', $name));
}
return $class_name::create($this->generator, $this->session, $options);
}
}