File: /var/www/dvpis2026/dvpis.kaunokolegija.lt/src/Controller/GoogleController.php
<?php
namespace App\Controller;
use Symfony\Component\Routing\Annotation\Route;
use KnpU\OAuth2ClientBundle\Client\ClientRegistry;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
class GoogleController extends AbstractController
{
/**
* Link to this controller to start the "connect" process
* @param ClientRegistry $clientRegistry
*
*
* @return RedirectResponse
*/
#[Route(path: '/connect/google', name: 'connect_google_start')]
public function connectAction(ClientRegistry $clientRegistry): RedirectResponse
{
return $clientRegistry
->getClient('google_connect')
->redirect([
'profile', 'email' // the scopes you want to access
])
;
}
/**
* After going to Google, you're redirected back here
* because this is the "redirect_route" you configured
* in config/packages/knpu_oauth2_client.yaml
*
* @param Request $request
* @param ClientRegistry $clientRegistry
*/
#[Route(path: '/connect/google/check', name: 'connect_google_check')]
public function connectCheckAction(Request $request, ClientRegistry $clientRegistry)
{
}
}