vendor/knpuniversity/oauth2-client-bundle/src/DependencyInjection/ProviderFactory.php line 44

Open in your IDE?
  1. <?php
  2. /*
  3.  * OAuth2 Client Bundle
  4.  * Copyright (c) KnpUniversity <http://knpuniversity.com/>
  5.  *
  6.  * For the full copyright and license information, please view the LICENSE
  7.  * file that was distributed with this source code.
  8.  */
  9. namespace KnpU\OAuth2ClientBundle\DependencyInjection;
  10. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  11. /**
  12.  * Used to create the individual Provider objects in the service container.
  13.  *
  14.  * You won't need to use this directly.
  15.  */
  16. class ProviderFactory
  17. {
  18.     /** @var UrlGeneratorInterface */
  19.     private $generator;
  20.     /**
  21.      * ProviderFactory constructor.
  22.      */
  23.     public function __construct(UrlGeneratorInterface $generator)
  24.     {
  25.         $this->generator $generator;
  26.     }
  27.     /**
  28.      * Creates a provider of the given class.
  29.      *
  30.      * @param string $class
  31.      * @param string $redirectUri
  32.      *
  33.      * @return mixed
  34.      */
  35.     public function createProvider($class, array $options$redirectUri, array $redirectParams = [], array $collaborators = [])
  36.     {
  37.         $redirectUri $this->generator
  38.             ->generate($redirectUri$redirectParamsUrlGeneratorInterface::ABSOLUTE_URL);
  39.         $options['redirectUri'] = $redirectUri;
  40.         return new $class($options$collaborators);
  41.     }
  42. }