/DependencyInjection/Security/Factory/FacebookFactory.php
http://github.com/FriendsOfSymfony/FOSFacebookBundle · PHP · 78 lines · 54 code · 14 blank · 10 comment · 1 complexity · e22247c615a518a90486ddb41e796375 MD5 · raw file
- <?php
- /*
- * This file is part of the FOSFacebookBundle package.
- *
- * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace FOS\FacebookBundle\DependencyInjection\Security\Factory;
- use Symfony\Component\DependencyInjection\ContainerBuilder;
- use Symfony\Component\DependencyInjection\Reference;
- use Symfony\Component\DependencyInjection\DefinitionDecorator;
- use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AbstractFactory;
- class FacebookFactory extends AbstractFactory
- {
- public function __construct()
- {
- $this->addOption('display', 'page');
- $this->addOption('app_url');
- $this->addOption('server_url');
- $this->addOption('create_user_if_not_exists', false);
- $this->addOption('redirect_to_facebook_login', true);
- }
- public function getPosition()
- {
- return 'pre_auth';
- }
- public function getKey()
- {
- return 'fos_facebook';
- }
- protected function getListenerId()
- {
- return 'fos_facebook.security.authentication.listener';
- }
- protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId)
- {
- $authProviderId = 'fos_facebook.auth.'.$id;
- $definition = $container
- ->setDefinition($authProviderId, new DefinitionDecorator('fos_facebook.auth'))
- ->replaceArgument(0, $id);
- // with user provider
- if (isset($config['provider'])) {
- $definition
- ->addArgument(new Reference($userProviderId))
- ->addArgument(new Reference('security.user_checker'))
- ->addArgument($config['create_user_if_not_exists'])
- ;
- }
- return $authProviderId;
- }
- protected function createEntryPoint($container, $id, $config, $defaultEntryPointId)
- {
- $entryPointId = 'fos_facebook.security.authentication.entry_point.'.$id;
- $container
- ->setDefinition($entryPointId, new DefinitionDecorator('fos_facebook.security.authentication.entry_point'))
- ->replaceArgument(1, $config)
- ;
- // set options to container for use by other classes
- $container->setParameter('fos_facebook.options.'.$id, $config);
- return $entryPointId;
- }
- }