<?php
/**
* Created by PhpStorm.
* User: PKDTECHNOLOGIESINC-K
* Date: 17/08/2019
* Time: 12:33
*/
namespace App\Controller\Fr;
use App\Entity\Products;
use App\Repository\MatPremiereRepository;
use App\Repository\ProductsRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\SerializerInterface;
class HomeFrController extends AbstractController
{
/**
* @Route("/", name="home")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function index()
{
return $this->render('views/index.html.twig');
}
/**
* @Route("/presentation", name="presentation")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function presentation()
{
return $this->render('views/presentation.html.twig');
}
/**
* @Route("/management", name="management")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function management()
{
return $this->render('views/management.html.twig');
}
/**
* @Route("/historique", name="historique")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function historique()
{
return $this->render('views/history.html.twig');
}
/**
* @Route("/role-du-courtier", name="role")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function role()
{
return $this->render('views/role.html.twig');
}
/**
* @Route("/marche-physique", name="physique")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function physique()
{
return $this->render('views/physique.html.twig');
}
/**
* @Route("/marche-a-terme", name="terme")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function terme()
{
return $this->render('views/terme.html.twig');
}
/**
* @Route("/structure-finance", name="structure")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function structure()
{
return $this->render('views/structurer.html.twig');
}
/**
* @Route("/prod-en-gestion", name="prod_en_gestion")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function proEnGestion()
{
return $this->render('views/prod-en-gestion.html.twig');
}
/**
* @Route("/actifs-sous-jacents", name="actifs_sous_jacents")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function actifSouJecents()
{
return $this->render('views/actifs-sous-jacents.html.twig');
}
/**
* @Route("/contact-us", name="contact")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function contact()
{
return $this->render('views/contact.html.twig');
}
/**
* @Route("/history", name="history")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function history()
{
return $this->render('views/historique.html.twig');
}
/**
* @Route("/mission/garantir-les-transactions", name="garantir")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function garantie()
{
return $this->render('views/missions/garantie.html.twig');
}
/**
* @Route("/mission/optimiser-vos-affaires", name="optimiser")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function optimise()
{
return $this->render('views/missions/optimise.html.twig');
}
/**
* @Route("/mission/delivrer-du-conseil-et-de-l-information", name="deliver")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function delivrer()
{
return $this->render('views/missions/delivrer.html.twig');
}
/**
* @Route("/mission/faciliter-l-acces-aux-marches-internatinaux", name="faciliter")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function faciliter()
{
return $this->render('views/missions/faciliter.html.twig');
}
/**
* @Route("/mission/gestion-des-capitaux", name="gestion-capitaux")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function gestion()
{
return $this->render('views/missions/gestion.html.twig');
}
/**
* @Route("/mission/couverture-et-arbitrage", name="couverture-arbitrage")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function arbitrage()
{
return $this->render('views/missions/arbitrage.html.twig');
}
/**
* @Route("/mission/conseils-et-informations", name="conseils-et-informations")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function strategie()
{
return $this->render('views/missions/strategies.html.twig');
}
/**
* @Route("/mission/negociation-et-services-intermediaires", name="negociation")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function negociation()
{
return $this->render('views/missions/negociations.html.twig');
}
/**
* @Route("/mission/mise-en-relation", name="relation")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function miseEnrelation()
{
return $this->render('views/missions/relation.html.twig');
}
/**
* @Route("/essai/{id}", name="matiere_by_product")
* @param Products $id
* @param SerializerInterface $serializer
* @param ProductsRepository $productsRepository
* @return Response
*/
public function getMatiereByProduct(Products $id, SerializerInterface $serializer, ProductsRepository $productsRepository, MatPremiereRepository $matPremiereRepository){
$matieres = $productsRepository->find($id);
// dd($matieres);
$encoder = new JsonEncoder();
$defaultContext = [
AbstractNormalizer::CIRCULAR_REFERENCE_HANDLER => function ($object, $format, $context) {
return $object->getName();
},
];
$normalizer = new ObjectNormalizer(null, null, null, null, null, null, $defaultContext);
$serializer = new Serializer([$normalizer], [$encoder]);
$data = $serializer->serialize($matieres, 'json');
return new Response($data, 200, [
'Content-Type' => 'application/json'
]);
}
}