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

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. private UrlGeneratorInterface $generator;
  19. /**
  20. * ProviderFactory constructor.
  21. */
  22. public function __construct(UrlGeneratorInterface $generator)
  23. {
  24. $this->generator = $generator;
  25. }
  26. /**
  27. * Creates a provider of the given class.
  28. *
  29. * @param string $class
  30. */
  31. public function createProvider($class, array $options, ?string $redirectUri = null, array $redirectParams = [], array $collaborators = [])
  32. {
  33. if (null !== $redirectUri) {
  34. $redirectUri = filter_var($redirectUri, \FILTER_VALIDATE_URL)
  35. ? $redirectUri
  36. : $this->generator->generate($redirectUri, $redirectParams, UrlGeneratorInterface::ABSOLUTE_URL);
  37. $options['redirectUri'] = $redirectUri;
  38. }
  39. return new $class($options, $collaborators);
  40. }
  41. }