src/Controller/OAuth/AbstractOAuthLoginController.php line 24

  1. <?php
  2. namespace Cms\Controller\OAuth;
  3. use Cms\Enum\PlatformEnum;
  4. use Cms\Repository\PlatformRepository;
  5. use Cms\String\SimpleAsciiSlugger;
  6. use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
  7. use Psr\Log\LoggerInterface;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. abstract class AbstractOAuthLoginController extends AbstractController
  12. {
  13.     public function __construct(
  14.         protected readonly PlatformRepository $platformRepository,
  15.         protected readonly SimpleAsciiSlugger $slugger,
  16.         protected readonly LoggerInterface $logger
  17.     ) {}
  18.     protected function doLogin(ClientRegistry $registryPlatformEnum $platform, array $redirect): Response
  19.     {
  20.         return $registry->getClient($platform->value.'_main')
  21.             ->redirect($redirect);
  22.     }
  23.     abstract public function login(ClientRegistry $registry): Response;
  24.     abstract public function connect(Request $requestClientRegistry $registry): void;
  25. }