<?php
namespace App\Controller;
use App\Entity\EquipmentReference;
use App\Entity\Option;
use App\Entity\WebAccess;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends AbstractController
{
/**
* @Route("/", name="home")
*/
public function index(): Response
{
$allService = $this->getDoctrine()->getRepository('App:WebAccess')->findAll();
return $this->render('default/home.html.twig', array('services' => $allService));
}
/**
* @Route("/importCSVaddressRIPMayenne", name="importCSVaddressRIPMayenne")
*/
public function importCSVaddressRIPMayenne(): Response
{
$csv = array_map('str_getcsv', file($this->getParameter('kernel.project_dir').'importRIPMayenne.csv'));
return $this->render(null);
}
/**
* @Route("/backend/parameters/", name="backend_parameters")
* @IsGranted("ROLE_ADMIN")
*/
public function homeAdmin(): Response
{
return $this->render('backend/homeAdmin.html.twig');
}
/**
* @Route("/testdata/add", name="app_add_test_data")
*/
public function addTestData(): Response
{
$allService = $this->getDoctrine()->getRepository('App:WebAccess')->findAll();
$option1 = new Option();
$option1->setCost(0);
$option1->setName("10 MB/s dédié");
$option1->setShortDescription("Débit garantie de 10Mb/s symétrique");
$option1->setSubscriptionPrice(10);
$option1->setCommissioningPrice(0);
$option1->setInternalCode("G-10");
$option1->setExecutionCode("FTTx-G-10");
$option2 = new Option();
$option2->setCost(0);
$option2->setName("20 Mb/s dédié");
$option2->setShortDescription("Débit garantie de 20Mb/s symétrique");
$option2->setSubscriptionPrice(20);
$option2->setCommissioningPrice(0);
$option2->setInternalCode("G-20");
$option2->setExecutionCode("FTTx-G-20");
$equipmentRef = new EquipmentReference();
$equipmentRef->setName("Hap AC3");
$equipmentRef->setCost(55);
$service = new WebAccess();
$service->setName("FTTH 100Mb/s");
$service->setAccessType('ffth');
$service->setExecutionCode('ffth');
$service->setPublicVisibility(true);
$service->setShortDescription("FTTH 100Mb/s symétrique");
$service->addOption($option1);
$service->addOption($option2);
$service->addEquipmentReference($equipmentRef);
$entityManager = $this->getDoctrine()->getManager();
//$entityManager->persist($service);
//$entityManager->flush();
return $this->render('default/home.html.twig', array('services' => $allService));
}
}