src/Controller/DefaultController.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\EquipmentReference;
  4. use App\Entity\Option;
  5. use App\Entity\WebAccess;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class DefaultController extends AbstractController
  11. {
  12.     /**
  13.      * @Route("/", name="home")
  14.      */
  15.     public function index(): Response
  16.     {
  17.         $allService $this->getDoctrine()->getRepository('App:WebAccess')->findAll();
  18.         return $this->render('default/home.html.twig', array('services' => $allService));
  19.     }
  20.     /**
  21.      * @Route("/importCSVaddressRIPMayenne", name="importCSVaddressRIPMayenne")
  22.      */
  23.     public function importCSVaddressRIPMayenne(): Response
  24.     {
  25.         $csv array_map('str_getcsv'file($this->getParameter('kernel.project_dir').'importRIPMayenne.csv'));
  26.         return $this->render(null);
  27.     }
  28.     /**
  29.      * @Route("/backend/parameters/", name="backend_parameters")
  30.      * @IsGranted("ROLE_ADMIN")
  31.      */
  32.     public function homeAdmin(): Response
  33.     {
  34.         return $this->render('backend/homeAdmin.html.twig');
  35.     }
  36.     /**
  37.      * @Route("/testdata/add", name="app_add_test_data")
  38.      */
  39.     public function addTestData(): Response
  40.     {
  41.         $allService $this->getDoctrine()->getRepository('App:WebAccess')->findAll();
  42.         $option1 = new Option();
  43.         $option1->setCost(0);
  44.         $option1->setName("10 MB/s dédié");
  45.         $option1->setShortDescription("Débit garantie de  10Mb/s symétrique");
  46.         $option1->setSubscriptionPrice(10);
  47.         $option1->setCommissioningPrice(0);
  48.         $option1->setInternalCode("G-10");
  49.         $option1->setExecutionCode("FTTx-G-10");
  50.         $option2 = new Option();
  51.         $option2->setCost(0);
  52.         $option2->setName("20 Mb/s dédié");
  53.         $option2->setShortDescription("Débit garantie de  20Mb/s symétrique");
  54.         $option2->setSubscriptionPrice(20);
  55.         $option2->setCommissioningPrice(0);
  56.         $option2->setInternalCode("G-20");
  57.         $option2->setExecutionCode("FTTx-G-20");
  58.         $equipmentRef = new EquipmentReference();
  59.         $equipmentRef->setName("Hap AC3");
  60.         $equipmentRef->setCost(55);
  61.         $service = new WebAccess();
  62.         $service->setName("FTTH 100Mb/s");
  63.         $service->setAccessType('ffth');
  64.         $service->setExecutionCode('ffth');
  65.         $service->setPublicVisibility(true);
  66.         $service->setShortDescription("FTTH 100Mb/s symétrique");
  67.         $service->addOption($option1);
  68.         $service->addOption($option2);
  69.         $service->addEquipmentReference($equipmentRef);
  70.         $entityManager $this->getDoctrine()->getManager();
  71.         //$entityManager->persist($service);
  72.         //$entityManager->flush();
  73.         return $this->render('default/home.html.twig', array('services' => $allService));
  74.     }
  75. }