<?php
namespace App\Controller;
use App\Entity\Testimony;
use App\Repository\LessonRepository;
use App\Repository\TestimonyRepository;
use Doctrine\ORM\EntityManagerInterface;
use Google\Client;
use Google\Service\Oauth2;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class Email extends AbstractController
{
public function google(
Request $request
) {
$client = new Client();
$client->setClientId("870305634351-esv1qf645qa5tsllgivul9kebktbbgdp.apps.googleusercontent.com");
$client->setClientSecret("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");
$client->setRedirectUri("https://coach.lndo.site/google");
$client->addScope("email");
$client->addScope("profile");
if ($request->get('code')) {
$token = $client->fetchAccessTokenWithAuthCode($_GET['code']);
$client->setAccessToken($token['access_token']);
// get profile info
// now you can use this profile info to create account in your website and make user logged in.
}
return $this->render("emails/index.html.twig", [
"items" => [],
"google" => $client->createAuthUrl()
]);
}
#[Route("/", name: "default")]
public function index(
)
{
return $this->redirectToRoute("admin_app_login");
$items = [];
$path = dirname(__DIR__,
2) . "/templates/emails";
foreach (scandir($path) as $file) {
if (!in_array($file,
[
".",
"..",
".DS_STORE"
]) && is_file($path . "/" . $file)) {
$items[] = "emails/" . $file;
} else {
foreach (scandir($path . "/" . $file) as $child) {
if (!in_array($file,
[
".",
"..",
".DS_STORE"
]) && is_file($path . "/" . $file . "/" . $child)) {
$items[] = "emails/" . $file . "/" . $child;
}
}
}
}
return $this->render("emails/index.html.twig",
["items" => $items]);
}
public function email(
Request $request, LessonRepository $lessonRepository, TestimonyRepository $testimonyRepository, EntityManagerInterface $entityManager
) {
return $this->render($request->query->get("path"),
[
"title" => "title",
"client" => true,
"lesson" => $lessonRepository->find(1)
]);
}
}