Closed okorneliuk closed 2 years ago
This could be one of elegant ways to provide redirect URI:
<?php
namespace App\OAuth2;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class RedirectUri implements \Stringable
{
private UrlGeneratorInterface $urlGenerator;
public function __construct(UrlGeneratorInterface $urlGenerator)
{
$this->urlGenerator = $urlGenerator;
}
public function __toString(): string
{
return $this->urlGenerator->generate('oauth2_connect_callback');
}
}
Closing the issue due to missing polyfills for Stringable
for PHP <7.1 and we should support >=5.6. At this point, we can cast to (string)
when initialize a provider.
I would like to have the ability to use class implementing
\Stringable
for redirect URI. If it makes sense, I can create a PR.