<?php
// src/Controller/LuckyController.php
namespace App\Controller;
use App\Entity\Miniclick\App;
use App\Repository\Verif\InformationsRepository;
use App\Service\Miniclick\MiniclickDbManager;
use App\Service\Miniclick\Render\RenderTopMenu;
use App\Service\Tool\Parsedown;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Annotation\Route;
class MainController extends AbstractController
{
private RenderTopMenu $miniclickRenderTopMenu ;
private MiniclickDbManager $miniclickDbManager ;
private SessionInterface $session ;
function __construct(RenderTopMenu $miniclickRenderTopMenu , MiniclickDbManager $miniclickDbManager, RequestStack $requestStack)
{
$this->miniclickRenderTopMenu = $miniclickRenderTopMenu ;
$this->miniclickDbManager = $miniclickDbManager;
$this->session = $requestStack->getSession() ;
}
#[Route("/",name:"app_main")]
public function main(InformationsRepository $informationsRepository)
{
$appRepo = $this->miniclickDbManager->getRepositoryForEntityClassName(App::class) ;
$app = $appRepo->find($this->session->get('current_app_id')) ;
$htmlMenu = $this->miniclickRenderTopMenu->render($app) ;
$categorie = 'dev_verif' ;
$contentsInformations = $informationsRepository->getContents($categorie) ;
$Parsedown = new Parsedown();
//$Parsedown->setSafeMode(true);
$Parsedown->setBreaksEnabled(true);
$contentsMarkdown = [] ;
foreach($contentsInformations as $key => $contentInformationTabs) {
foreach($contentInformationTabs as $contentInformation) {
$contentsMarkdown[$key][] = $Parsedown->text($contentInformation->getTexte()) ;
}
}
return $this->render('main.html.twig',['menu'=>$htmlMenu,'contentsInformations'=>$contentsInformations,'contentsMarkdown'=>$contentsMarkdown]);
}
#[Route("/flash",name:"empty_main")]
public function empty(Request $request)
{
$parameters = [] ;
if($request->query->get('do_datagrid_reload',0) == 1 ) {
$parameters['do_datagrid_reload'] = 1 ;
}
if($request->query->get('do_close_modale',0) == 1 ) {
$parameters['do_close_modale'] = 1 ;
}
return $this->render('base.html.twig',$parameters);
}
/**
* @Route("/is_user_connected",name="is_user_connected")
*/
public function isusersession(Request $request)
{
return $this->json(array('ok'=>true,'message'=>'connecté'));
}
}