Source of file InMemoryFactory.php
Size: 2,284 Bytes - Last Modified: 2013-07-17T08:22:21+02:00
/home/theseer/Downloads/Symfony/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/UserProvider/InMemoryFactory.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 | <?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * InMemoryFactory creates services for the memory provider. * * @author Fabien Potencier <fabien@symfony.com> * @author Christophe Coevoet <stof@notk.org> */ class InMemoryFactory implements UserProviderFactoryInterface { public function create(ContainerBuilder $container, $id, $config) { $definition = $container->setDefinition($id, new DefinitionDecorator('security.user.provider.in_memory')); foreach ($config['users'] as $username => $user) { $userId = $id.'_'.$username; $container ->setDefinition($userId, new DefinitionDecorator('security.user.provider.in_memory.user')) ->setArguments(array($username, (string) $user['password'], $user['roles'])) ; $definition->addMethodCall('createUser', array(new Reference($userId))); } } public function getKey() { return 'memory'; } public function addConfiguration(NodeDefinition $node) { $node ->fixXmlConfig('user') ->children() ->arrayNode('users') ->useAttributeAsKey('name') ->prototype('array') ->children() ->scalarNode('password')->defaultValue(uniqid())->end() ->arrayNode('roles') ->beforeNormalization()->ifString()->then(function($v) { return preg_split('/\s*,\s*/', $v); })->end() ->prototype('scalar')->end() ->end() ->end() ->end() ->end() ->end() ; } } |