src/Service/AppService.php line 145

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. use App\Entity\Application;
  4. use App\Entity\Category;
  5. use App\Entity\History;
  6. use App\Entity\JobOffer;
  7. use App\Entity\LandingSlider;
  8. use App\Entity\Page;
  9. use App\Entity\Post;
  10. use App\Entity\Product;
  11. use App\Entity\ProductTable;
  12. use App\Entity\ProductTableColumn;
  13. use App\Entity\ProductTableRow;
  14. use App\Entity\Project;
  15. use App\Entity\SubCategory;
  16. use App\Entity\SubSubCategory;
  17. use App\Entity\SubSubSubCategory;
  18. use App\Serializer\ProjectNormalizer;
  19. use Symfony\Bridge\Twig\Mime\BodyRenderer;
  20. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  21. use Symfony\Component\HttpFoundation\RequestStack;
  22. use Doctrine\ORM\EntityManagerInterface;
  23. use Psr\Log\LoggerInterface;
  24. use Symfony\Component\Mailer\Mailer;
  25. use Symfony\Component\Mailer\MailerInterface;
  26. use Symfony\Component\Mailer\Transport;
  27. use Symfony\Component\PropertyAccess\PropertyAccess;
  28. use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
  29. use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
  30. use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
  31. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  32. use Symfony\Component\Security\Core\Security;
  33. use Symfony\Component\Serializer\Encoder\JsonEncoder;
  34. use Symfony\Component\Serializer\Encoder\XmlEncoder;
  35. use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
  36. use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
  37. use Symfony\Component\Serializer\Serializer;
  38. use \DrewM\MailChimp\MailChimp;
  39. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  40. use Symfony\Contracts\Translation\TranslatorInterface;
  41. use Twig\Environment;
  42. use Twig\Extension\AbstractExtension;
  43. use Twig\Loader\FilesystemLoader;
  44. use Twig\TwigFunction;
  45. class AppService extends AbstractExtension
  46. {
  47.     protected $entityManager;
  48.     protected $router;
  49.     protected $logger;
  50.     protected $security;
  51.     protected $requestStack;
  52.     protected $mailer;
  53.     protected $mailer_user;
  54.     protected $mailer_dsn;
  55.     protected $parameterBag;
  56.     protected $translator;
  57.     public function __construct(RequestStack $requestStackSecurity $securityEntityManagerInterface $entityManagerUrlGeneratorInterface $routerLoggerInterface $logger$mailer_userMailerInterface $mailer$mailer_dsnParameterBagInterface $parameterBagTranslatorInterface $translator)
  58.     {
  59.         $this->em $entityManager;
  60.         $this->logger $logger;
  61.         $this->router $router;
  62.         $this->security $security;
  63.         $this->requestStack $requestStack;
  64.         $this->mailer_user $mailer_user;
  65.         $this->mailer $mailer;
  66.         $this->mailer_dsn $mailer_dsn;
  67.         $this->parameterBag $parameterBag;
  68.         $this->translator $translator;
  69.     }
  70.     public function getFunctions(): array
  71.     {
  72.         return [
  73.             new TwigFunction('getFormattedDate', [$this'getFormattedDate']),
  74.             new TwigFunction('getPage', [$this'getPage']),
  75.             new TwigFunction('getLinksNav', [$this'getLinksNav']),
  76.             new TwigFunction('getHistories', [$this'getHistories']),
  77.             new TwigFunction('getProjectsMap', [$this'getProjectsMap']),
  78.             new TwigFunction('getLandingSliders', [$this'getLandingSliders']),
  79.             new TwigFunction('getSubCategories', [$this'getSubCategories']),
  80.             new TwigFunction('getSubSubCategories', [$this'getSubSubCategories']),
  81.             new TwigFunction('getSubSubSubCategories', [$this'getSubSubSubCategories']),
  82.             new TwigFunction('getCategories', [$this'getCategories']),
  83.             new TwigFunction('getSitemapLinks', [$this'getSitemapLinks']),
  84.             new TwigFunction('strEndsWith', [$this'strEndsWith']),
  85.             new TwigFunction('getPropTrans', [$this'getPropTrans']),
  86.             new TwigFunction('isCrudTextEditor', [$this'isCrudTextEditor']),
  87.             new TwigFunction('getProducts', [$this'getProducts']),
  88.             new TwigFunction('getProductUrl', [$this'getProductUrl']),
  89.             new TwigFunction('getMetaColor', [$this'getMetaColor']),
  90.             new TwigFunction('getGoogleAnalytic', [$this'getGoogleAnalytic']),
  91.             new TwigFunction('getGoogleSearchConsole', [$this'getGoogleSearchConsole']),
  92.             new TwigFunction('getApplications', [$this'getApplications']),
  93.             new TwigFunction('getCategoryMenu', [$this'getCategoryMenu']),
  94.             new TwigFunction('getClass', [$this'getClass']),
  95.             new TwigFunction('getSubValues', [$this'getSubValues']),
  96.             new TwigFunction('getCategoryImage', [$this'getCategoryImage']),
  97.             new TwigFunction('getValueLevel', [$this'getValueLevel']),
  98.             new TwigFunction('getValueColor', [$this'getValueColor']),
  99.             new TwigFunction('getProductValue', [$this'getProductValue']),
  100.             new TwigFunction('getProductTableColums', [$this'getProductTableColums']),
  101.             new TwigFunction('getProductTableRows', [$this'getProductTableRows']),
  102.             new TwigFunction('getSubCategory', [$this'getSubCategory']),
  103.             new TwigFunction('getProductMenu', [$this'getProductMenu']),
  104.         ];
  105.     }
  106.     public function getProductTableRows(ProductTableColumn $productTableColumn)
  107.     {
  108.         $repoProductTableRow $this->em->getRepository(ProductTableRow::class);
  109.         $productTableRows $repoProductTableRow->findBy(["productTableColumn" => $productTableColumn], ["position" => "asc"]);
  110.         return $productTableRows;
  111.     }
  112.     public function getProductTableColums(ProductTable $productTable)
  113.     {
  114.         $repoProductTableColumn $this->em->getRepository(ProductTableColumn::class);
  115.         $productTableColumns $repoProductTableColumn->findBy(["productTable" => $productTable], ["position" => "asc"]);
  116.         return $productTableColumns;
  117.     }
  118.     public function getSubValues($value)
  119.     {
  120.         $valueClass $this->getClass($value);
  121.         $repoSubValue $this->em->getRepository(("App\Entity\Sub" $valueClass));
  122.         return $repoSubValue->findBy([(lcfirst($valueClass)) => $value], ["position" => "asc"]);
  123.     }
  124.     public function getRoutesControllers()
  125.     {
  126.         $routes $this->getRoutes();
  127.         $controllers = [];
  128. //        $controllers["Aucun"] = null;
  129.         foreach ($routes as $key => $route) {
  130.             $controllers[$route->getPath()] = $route->getDefault('_controller');
  131.         }
  132.         return $controllers;
  133.     }
  134.     public function getPage($controller)
  135.     {
  136.         $repoPage $this->em->getRepository(Page::class);
  137.         $page $repoPage->findOneBy(["controller" => $controller]);
  138.         return $page;
  139.     }
  140.     public function getRoute($controller)
  141.     {
  142.         $routes $this->getRoutes();
  143.         foreach ($routes as $key => $route) {
  144.             if ($route->getDefault('_controller') == $controller) {
  145.                 return $route;
  146.             }
  147.         }
  148.         return null;
  149.     }
  150.     public function getRoutes()
  151.     {
  152.         $router $this->router;
  153.         $routes $router->getRouteCollection()->all();
  154.         foreach ($routes as $key => $route) {
  155.             if (strpos($route->getDefault('_controller'), "App\Controller") === false) {
  156.                 unset($routes[$key]);
  157.             }
  158.         }
  159.         return $routes;
  160.     }
  161.     public function getLandingSliders()
  162.     {
  163.         $repoLandingSlider $this->em->getRepository(LandingSlider::class);
  164.         return $repoLandingSlider->findBy([], ["position" => "asc"]);
  165.     }
  166.     public function getProjectsMap($format null$data = [])
  167.     {
  168.         $encoders = [new XmlEncoder(), new JsonEncoder()];
  169.         $normalizers = [new ProjectNormalizer(new ObjectNormalizer())];
  170. //        $normalizers = [new ObjectNormalizer()];
  171.         $serializer = new Serializer($normalizers$encoders);
  172.         $repoProject $this->em->getRepository(Project::class);
  173.         $projects $repoProject->search($data);
  174.         return $format == "json" $serializer->serialize($projects'json', [AbstractNormalizer::ATTRIBUTES => ['latitude''longitude''id''title']]) : $projects;
  175.     }
  176.     public function suscribeToList($email)
  177.     {
  178.         try {
  179.             $MailChimp = new MailChimp('api_key');
  180. //            dump($MailChimp->get('lists'));
  181. //            exit;
  182.             // prendre l'id de la liste et non le webId
  183.             $list_id "list_id";
  184.             $result $MailChimp->post("lists/$list_id/members", [
  185.                 'email_address' => $email,
  186.                 'status' => 'subscribed',
  187.             ]);
  188.         } catch (\Exception $e) {
  189.         }
  190.     }
  191.     public function getPropertyInfo()
  192.     {
  193.         $phpDocExtractor = new PhpDocExtractor();
  194.         $reflectionExtractor = new ReflectionExtractor();
  195.         $listExtractors = [$reflectionExtractor];
  196.         $typeExtractors = [$phpDocExtractor$reflectionExtractor];
  197.         return new PropertyInfoExtractor(
  198.             $listExtractors,
  199.             $typeExtractors
  200.         );
  201.     }
  202.     public function isCrudTextEditor($name)
  203.     {
  204.         $arr = [
  205.             "description",
  206.             "intro",
  207.             "content",
  208.         ];
  209.         foreach ($arr as $key => $haystack) {
  210.             if (str_contains($haystack$name)) {
  211.                 return true;
  212.             }
  213.         }
  214.         return false;
  215.     }
  216.     public function getCrudProps($namespace)
  217.     {
  218.         $propertyInfo $this->getPropertyInfo();
  219.         $properties = ($propertyInfo->getProperties($namespace) ?? []);
  220.         $props = [];
  221.         $noProp = ["currentLocale""defaultLocale""translatable""locale""empty""id"];
  222.         foreach ($properties as $key => $value) {
  223.             $propertyType $propertyInfo->getTypes($namespace$value)[0];
  224.             if (!in_array($value$noProp) and !str_ends_with($value"FileSize") and !str_ends_with($value"FileUpdatedAt")
  225.                 and !str_contains($value"FileName") and !$propertyType->isCollection()) {
  226.                 $type = ($propertyType->getClassName() ? "ManyToOne" $propertyType->getBuiltinType());
  227.                 $props[] = [
  228.                     "name" => $value,
  229.                     "type" => $type
  230.                 ];
  231.             }
  232.         }
  233.         return $props;
  234.     }
  235.     public function getMetaColor()
  236.     {
  237.         $repoPage $this->em->getRepository(Page::class);
  238.         $page $repoPage->search(["notNull" => ["a.metaColor"], "limit" => 1]);
  239.         return $page $page->getMetaColor() : null;
  240.     }
  241.     public function getGoogleSearchConsole()
  242.     {
  243.         $repoPage $this->em->getRepository(Page::class);
  244.         $page $repoPage->search(["notNull" => ["a.googleSearchConsole"], "limit" => 1]);
  245.         return $page $page->getGoogleSearchConsole() : null;
  246.     }
  247.     public function getGoogleAnalytic()
  248.     {
  249.         $repoPage $this->em->getRepository(Page::class);
  250.         $page $repoPage->search(["notNull" => ["a.googleAnalytic"], "limit" => 1]);
  251.         return $page $page->getGoogleAnalytic() : null;
  252.     }
  253.     public function getClass($object$prefix false)
  254.     {
  255.         return ($prefix "App\Entity\\" "") . (new \ReflectionClass($object))->getShortName();
  256.     }
  257.     public function getCategoryMenu(Category $category nullSubCategory $subCategory nullSubSubCategory $subSubCategory nullSubSubSubCategory $subSubSubCategory null)
  258.     {
  259.         $menu = [];
  260.         if ($category) {
  261.             $menu = [$category->getTitle() => $this->getProductUrl(nulltrue$category)];
  262.         }
  263.         if ($subCategory) {
  264.             $menu[$subCategory->getTitle()] = $this->getProductUrl(nulltruenull$subCategory);
  265.         }
  266.         if ($subSubCategory) {
  267.             $menu[$subSubCategory->getTitle()] = $this->getProductUrl(nulltruenullnull$subSubCategory);
  268.         }
  269.         if ($subSubSubCategory) {
  270.             $menu[$subSubSubCategory->getTitle()] = $this->getProductUrl(nulltruenullnullnull$subSubSubCategory);
  271.         }
  272.         return $menu;
  273.     }
  274.     public function getValueLevel($value)
  275.     {
  276.         $class $this->getClass($value1);
  277.         if ($class == Category::class) {
  278.             return 1;
  279.         } elseif ($class == SubCategory::class) {
  280.             return 2;
  281.         } elseif ($class == SubSubCategory::class) {
  282.             return 3;
  283.         } else {
  284.             return 4;
  285.         }
  286.     }
  287.     public function getLevelInfo()
  288.     {
  289.         return [
  290.             => [
  291.                 "underName" => "category"
  292.             ],
  293.             => [
  294.                 "underName" => "sub_category"
  295.             ],
  296.             => [
  297.                 "underName" => "sub_sub_category"
  298.             ],
  299.             => [
  300.                 "underName" => "sub_sub_sub_category"
  301.             ],
  302.         ];
  303.     }
  304.     public function getValueColor($value)
  305.     {
  306.         $levelInfo $this->getLevelInfo();
  307.         $propertyAccessor PropertyAccess::createPropertyAccessor();
  308.         $level $this->getValueLevel($value);
  309.         $color null;
  310.         while (1) {
  311.             if ($level == 1) {
  312.                 $color $value->getColor();
  313.             }
  314.             $level--;
  315.             if (!$level) {
  316.                 break;
  317.             } else {
  318.                 $value $propertyAccessor->getValue($value$levelInfo[$level]["underName"]);
  319.             }
  320.         }
  321.         return $color;
  322.     }
  323.     public function getProductMenu(Product $product)
  324.     {
  325.         $subSubSubCategory $product->getSubSubSubCategory();
  326.         $subSubCategory $product->getSubSubCategory();
  327.         $subCategory $product->getSubCategory();
  328.         $category $product->getCategory();
  329.         if ($subSubSubCategory) {
  330.             $subSubCategory $subSubSubCategory->getSubSubCategory();
  331.             $subCategory $subSubCategory->getSubCategory();
  332.             $category $subCategory->getCategory();
  333.         }
  334.         if ($subSubCategory) {
  335.             $subCategory $subSubCategory->getSubCategory();
  336.             $category $subCategory->getCategory();
  337.         }
  338.         if ($subCategory) {
  339.             $category $subCategory->getCategory();
  340.         }
  341.         $menu $this->getCategoryMenu($category$subCategory$subSubCategory$subSubSubCategory);
  342.         $menu[$product->getTitle()] = "#";
  343.         return $menu;
  344.     }
  345.     public function getSubCategory(Product $product)
  346.     {
  347.         $subCategory null;
  348.         if ($product->getSubCategory()) {
  349.             $subCategory $product->getSubCategory();
  350.         }
  351.         if (!$subCategory) {
  352.             $subCategory $product->getSubSubCategory() ? $product->getSubSubCategory()->getSubCategory() : null;
  353.         }
  354.         if (!$subCategory) {
  355.             $subCategory $product->getSubSubSubCategory() and $product->getSubSubSubCategory()->getSubSubCategory() ? $product->getSubSubSubCategory()->getSubSubCategory()->getSubCategory() : null;
  356.         }
  357.         return $subCategory;
  358.     }
  359.     public function getProductValue(Product $product)
  360.     {
  361.         if ($product->getSubSubSubCategory()) {
  362.             return $product->getSubSubSubCategory();
  363.         }
  364.         if ($product->getSubSubCategory()) {
  365.             return $product->getSubSubCategory();
  366.         }
  367.         if ($product->getSubCategory()) {
  368.             return $product->getSubCategory();
  369.         }
  370.         if ($product->getCategory()) {
  371.             return $product->getCategory();
  372.         }
  373.         return null;
  374.     }
  375.     public function getCategoryImage($value$isIcon false$isRecursive false$isBg false)
  376.     {
  377.         $levelInfo $this->getLevelInfo();
  378.         $propertyAccessor PropertyAccess::createPropertyAccessor();
  379.         $level $this->getValueLevel($value);
  380.         while (1) {
  381.             $img $propertyAccessor->getValue($value$levelInfo[$level]["underName"] . ($isIcon "Icon" : ($isBg "Bg" "")) . '_file_name');
  382.             $level--;
  383.             if (!$img and $level and $isRecursive) {
  384.                 $value $propertyAccessor->getValue($value$levelInfo[$level]["underName"]);
  385.             } else {
  386.                 break;
  387.             }
  388.         }
  389.         return $img ? ("/upload/" lcfirst($this->getClass($value)) . ($isIcon "Icon" : ($isBg "Bg" "")) . "/" $img) : ($isIcon "/assets/img/default_cat_icon_img.svg" : ($isBg "/assets/img/default_cat_img_bg.png" "/assets/img/sans-img-1-dmd-inox.jpg"));
  390.     }
  391.     public
  392.     function getProductUrl(Product $product null$isCatRoute falseCategory $category nullSubCategory $subCategory nullSubSubCategory $subSubCategory nullSubSubSubCategory $subSubSubCategory null$value null)
  393.     {
  394.         if ($value) {
  395.             if ($this->getClass($value1) == Category::class) {
  396.                 $category $value;
  397.             } elseif ($this->getClass($value1) == SubCategory::class) {
  398.                 $subCategory $value;
  399.             } elseif ($this->getClass($value1) == SubSubCategory::class) {
  400.                 $subSubCategory $value;
  401.             } elseif ($this->getClass($value1) == SubSubSubCategory::class) {
  402.                 $subSubSubCategory $value;
  403.             }
  404.         }
  405.         $catSlug $subCatSlug $subSubCatSlug $subSubSubCatSlug "0";
  406.         if ($product) {
  407.             $subSubSubCategory $product->getSubSubSubCategory();
  408.             if (!$subSubSubCategory) {
  409.                 $subSubCategory $product->getSubSubCategory();
  410.                 if (!$subSubCategory) {
  411.                     $subCategory $product->getSubCategory();
  412.                     if (!$subCategory) {
  413.                         $category $product->getCategory();
  414.                     }
  415.                 }
  416.             }
  417.         }
  418.         if ($category) {
  419.             $catSlug $category->getSlug();
  420.         } elseif ($subCategory) {
  421.             $catSlug $subCategory->getCategory()->getSlug();
  422.             $subCatSlug $subCategory->getSlug();
  423.         } elseif ($subSubCategory) {
  424.             $catSlug $subSubCategory->getSubCategory()->getCategory()->getSlug();
  425.             $subCatSlug $subSubCategory->getSubCategory()->getSlug();
  426.             $subSubCatSlug $subSubCategory->getSlug();
  427.         } elseif ($subSubSubCategory) {
  428.             $catSlug $subSubSubCategory->getSubSubCategory()->getSubCategory()->getCategory()->getSlug();
  429.             $subCatSlug $subSubSubCategory->getSubSubCategory()->getSubCategory()->getSlug();
  430.             $subSubCatSlug $subSubSubCategory->getSubSubCategory()->getSlug();
  431.             $subSubSubCatSlug $subSubSubCategory->getSlug();
  432.         }
  433.         if ($product) {
  434.             return $this->router->generate("front_product", ["catSlug" => $catSlug"subCatSlug" => $subCatSlug"subSubCatSlug" => $subSubCatSlug"subSubSubCatSlug" => $subSubSubCatSlug"slug" => $product->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  435.         } else {
  436.             $data = ["slug" => $catSlug"subCatSlug" => $subCatSlug"subSubCatSlug" => $subSubCatSlug];
  437.             if ($isCatRoute and !$subSubSubCategory) {
  438.                 $route "front_category";
  439.             } else {
  440.                 $route "front_products";
  441.                 $data["subSubSubCatSlug"] = $subSubSubCatSlug;
  442.             }
  443.             return $this->router->generate($route$dataUrlGeneratorInterface::ABSOLUTE_URL);
  444.         }
  445.     }
  446.     public
  447.     function getPropField($type)
  448.     {
  449.         return "Field";
  450.     }
  451.     public
  452.     function getSubCategories($categoryId$limit null)
  453.     {
  454.         $repoSubCategory $this->em->getRepository(SubCategory::class);
  455.         return $repoSubCategory->findBy(["category" => $categoryId], ["position" => 'asc'], $limit);
  456.     }
  457.     public
  458.     function getSubSubCategories($subCategoryId)
  459.     {
  460.         $repoSubSubCategory $this->em->getRepository(SubSubCategory::class);
  461.         return $repoSubSubCategory->findBy(["subCategory" => $subCategoryId], ["position" => 'asc']);
  462.     }
  463.     public
  464.     function getSubSubSubCategories($subSubCategoryId)
  465.     {
  466.         $repoSubSubSubCategory $this->em->getRepository(SubSubSubCategory::class);
  467.         return $repoSubSubSubCategory->findBy(["subSubCategory" => $subSubCategoryId], ["position" => 'asc']);
  468.     }
  469.     public
  470.     function getProducts(SubCategory $subCategory)
  471.     {
  472.         $repoProduct $this->em->getRepository(Product::class);
  473.         $products $repoProduct->findBy(["subCategory" => $subCategory], ["position" => "asc"]);
  474.         return $products;
  475.     }
  476.     public
  477.     function getCategories()
  478.     {
  479.         $repoCategory $this->em->getRepository(Category::class);
  480.         return $repoCategory->findBy([], ["position" => "asc"]);
  481.     }
  482.     public
  483.     function getHistories()
  484.     {
  485.         $repoHistory $this->em->getRepository(History::class);
  486.         return $repoHistory->findBy([], ["year" => "asc"]);
  487.     }
  488.  public function getApplications(Application $application null)
  489.     {
  490.         $repoApplication $this->em->getRepository(Application::class);
  491.         if ($application) {
  492.             $applications $repoApplication->search(["orderBys" => ["a.position" => "asc"], "different" => ["a.id" => $application->getId()]]);
  493.         } else {
  494.             $applications $repoApplication->findBy([], ["position" => "asc"]);
  495.         }
  496.         return $applications;
  497.     }
  498.     public
  499.     function getFormattedDate(\DateTime $dateTime$days true)
  500.     {
  501.         $translatedDays = [
  502.             => "Lundi",
  503.             => "Mardi",
  504.             => "Mercredi",
  505.             => "Jeudi",
  506.             => "Vendredi",
  507.             => "Samedi",
  508.             => "Dimanche",
  509.         ];
  510.         $translatedMonths = [
  511.             => "Janvier",
  512.             => "Février",
  513.             => "Mars",
  514.             => "Avril",
  515.             => "Mai",
  516.             => "Juin",
  517.             => "Juillet",
  518.             => "Août",
  519.             => "Septembre",
  520.             10 => "Octobre",
  521.             11 => "Novembre",
  522.             12 => "Décembre"
  523.         ];
  524.         return (($days ? ($translatedDays[$dateTime->format("N")] . " ") : "") . $dateTime->format("j") . " " $translatedMonths[$dateTime->format("n")] . " " $dateTime->format("Y"));
  525.     }
  526.     public
  527.     function getPropTrans($name)
  528.     {
  529.         if ($name == "name") {
  530.             return "Nom";
  531.         } else if ($name == "firstname") {
  532.             return "Prénom";
  533.         } else if ($name == "lastname") {
  534.             return "Nom";
  535.         } else if ($name == "zipCode") {
  536.             return "Code postal";
  537.         } else if ($name == "address") {
  538.             return "Adresse";
  539.         } else if ($name == "city") {
  540.             return "Ville";
  541.         } else if ($name == "title") {
  542.             return "Titre";
  543.         } else if ($name == "category") {
  544.             return "Catégorie";
  545.         } else if ($name == "subCategory") {
  546.             return "Sous-catégorie";
  547.         } else if ($name == "subSubCategory") {
  548.             return "Sous-sous-catégorie";
  549.         } else if ($name == "color") {
  550.             return "Couleur";
  551.         } else if ($name == "content") {
  552.             return "Contenu";
  553.         } else if ($name == "metaTitle") {
  554.             return "Balise titre";
  555.         } else if ($name == "metaDescription") {
  556.             return "Balise description";
  557.         } else if ($name == "paragraphs") {
  558.             return "Paragraphe";
  559.         } else if ($name == "isDeleted") {
  560.             return "Supprimer";
  561.         } else if ($name == "link") {
  562.             return "Lien";
  563.         } else if ($name == "legend") {
  564.             return "Légende";
  565.         } else if ($name == "jobFunction") {
  566.             return "Fonction";
  567.         } else if ($name == "phoneNumber") {
  568.             return "Téléphone";
  569.         } else if ($name == "email") {
  570.             return "Adresse email";
  571.         } else if ($name == "subtitle" or $name == "Subtitle") {
  572.             return "Sous-titre";
  573.         } else if ($name == "createdAt") {
  574.             return "Date de création";
  575.         } else if ($name == "date") {
  576.             return "Date";
  577.         } else if ($name == "product") {
  578.             return "Produit";
  579.         }
  580.         return ucfirst($name);
  581.     }
  582.     public
  583.     function getSitemapLinks()
  584.     {
  585.         $links = [
  586.             $this->router->generate('front_landing', [], UrlGeneratorInterface::ABSOLUTE_URL),
  587.             $this->router->generate('front_contact', [], UrlGeneratorInterface::ABSOLUTE_URL),
  588.             $this->router->generate('front_posts', [], UrlGeneratorInterface::ABSOLUTE_URL),
  589.             $this->router->generate('front_fabrication', [], UrlGeneratorInterface::ABSOLUTE_URL),
  590.             $this->router->generate('front_presentation', [], UrlGeneratorInterface::ABSOLUTE_URL),
  591.             $this->router->generate('front_documents', [], UrlGeneratorInterface::ABSOLUTE_URL),
  592.         ];
  593.         $repoPost $this->em->getRepository(Post::class);
  594.         foreach ($repoPost->findAll() as $key => $post) {
  595.             $links[] = $this->router->generate('front_post', ["slug" => $post->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  596.         }
  597.         $repoCategory $this->em->getRepository(Category::class);
  598.         foreach ($repoCategory->findAll() as $key => $category) {
  599.             $links[] = $this->getProductUrl(nulltrue$category);
  600.         }
  601.         $repoSubCategory $this->em->getRepository(SubCategory::class);
  602.         foreach ($repoSubCategory->findAll() as $key => $subCategory) {
  603.             $links[] = $this->getProductUrl(nulltruenull$subCategory);
  604.         }
  605.         $repoSubSubCategory $this->em->getRepository(SubSubCategory::class);
  606.         foreach ($repoSubSubCategory->findAll() as $key => $subSubCategory) {
  607.             $links[] = $this->getProductUrl(nulltruenullnull$subSubCategory);
  608.         }
  609.         $repoSubSubSubCategory $this->em->getRepository(SubSubSubCategory::class);
  610.         foreach ($repoSubSubSubCategory->findAll() as $key => $subSubSubCategory) {
  611.             $links[] = $this->getProductUrl(nulltruenullnullnull$subSubSubCategory);
  612.         }
  613.         $repoApplication $this->em->getRepository(Application::class);
  614.         foreach ($repoApplication->findAll() as $key => $application) {
  615.             $links[] = $this->router->generate('front_application', ["slug" => $application->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  616.         }
  617.         $repoProduct $this->em->getRepository(Product::class);
  618.         foreach ($repoProduct->findAll() as $key => $product) {
  619.             $links[] = $this->getProductUrl($product);
  620.         }
  621.         return $links;
  622.     }
  623.     public
  624.     function strEndsWith($haystack$needle)
  625.     {
  626.         return str_ends_with($haystack$needle);
  627.     }
  628.     public
  629.     function getLinksNav()
  630.     {
  631.          $applications $this->getApplications();
  632.         foreach ($applications as $key => $application) {
  633.             $applicationLinks[$application->getTitle()] = $this->router->generate('front_application', ["slug" => $application->getSlug()]);
  634.         }
  635.         return [
  636. //           ($this->translator->trans("navbar.home")) => $this->router->generate('front_landing'),
  637. //            ($this->translator->trans("navbar.skills")) => $skillLinks,
  638. //            ($this->translator->trans("navbar.products")) => $categoryLinks,
  639.             ($this->translator->trans("footer.products.fab")) => $this->router->generate('front_fabrication'),
  640.             ($this->translator->trans("menu.applications")) => $applicationLinks,
  641.             ($this->translator->trans("footer.menu.about")) => $this->router->generate('front_presentation'),
  642.             ($this->translator->trans("footer.menu.posts")) => $this->router->generate('front_posts'),
  643.             ($this->translator->trans("footer.menu.download")) => $this->router->generate('front_documents'),
  644.             ($this->translator->trans("footer.menu.contact")) => $this->router->generate('front_contact'),
  645.         ];
  646.     }
  647. }