<?php
namespace App\Controller;
use Algolia\AlgoliaSearch\SearchClient;
use App\Form\Model\Settings;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
#[Route('/config')]
class ConfigController extends AbstractController
{
public function __construct(protected TranslatorInterface $translator)
{
}
#[Route(path: '/javascript-settings.js', name: 'front_config_javascriptSettings')]
public function javascriptSettings(): Response
{
/*$securedApiKey = SearchClient::generateSecuredApiKey(
Settings::get('algoliaFrontEndApiKey'),
[
'filters' => '(locale:' . $request->getLocale() . ') AND (type:page OR type:case-study OR type:home OR type:team-member) AND status:published AND visibility:public AND visible:true',
'attributesToRetrieve' => [
'globalDescription',
'globalTitle',
'path',
'status',
'title',
'description',
'locale'
],
]
);*/
$tradList = [];
$translations = [];
foreach ($tradList as $trad) {
$translations[$trad] = $this->translator->trans($trad);
}
$response = new Response($this->renderView('front/config/javascript-settings.js.twig', [
'trads' => $translations,
// 'algoliaApiKey' => $securedApiKey,
]));
$response->headers->set('Content-Type', 'text/javascript');
return $response;
}
}