src/Service/AppService.php line 168

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. use App\Entity\Category;
  4. use App\Entity\History;
  5. use App\Entity\JobOffer;
  6. use App\Entity\LandingPage;
  7. use App\Entity\LandingSlider;
  8. use App\Entity\Page;
  9. use App\Entity\PhaseEvolution;
  10. use App\Entity\Post;
  11. use App\Entity\Product;
  12. use Symfony\Contracts\Translation\TranslatorInterface;
  13. use App\Entity\ProductBrochure;
  14. use App\Entity\ProductBrochurePdf;
  15. use App\Entity\ProductHardwareProductAddon;
  16. use App\Entity\ProductKeyFeature;
  17. use App\Entity\ProductParagraph;
  18. use App\Entity\ProductProduct;
  19. use App\Entity\ProductProductBrochure;
  20. use App\Entity\ProductProductMedia;
  21. use App\Entity\ProductPublication;
  22. use App\Entity\ProductSoftwareProductAddon;
  23. use App\Entity\ProductSubCategory;
  24. use App\Entity\Project;
  25. use App\Entity\Publication;
  26. use App\Entity\SubCategory;
  27. use App\Serializer\ProjectNormalizer;
  28. use Doctrine\Common\Collections\ArrayCollection;
  29. use Symfony\Bridge\Twig\Mime\BodyRenderer;
  30. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  31. use Symfony\Component\HttpFoundation\RequestStack;
  32. use Doctrine\ORM\EntityManagerInterface;
  33. use Psr\Log\LoggerInterface;
  34. use Symfony\Component\Mailer\Mailer;
  35. use Symfony\Component\Mailer\MailerInterface;
  36. use Symfony\Component\Mailer\Transport;
  37. use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
  38. use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
  39. use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
  40. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  41. use Symfony\Component\Security\Core\Security;
  42. use Symfony\Component\Serializer\Encoder\JsonEncoder;
  43. use Symfony\Component\Serializer\Encoder\XmlEncoder;
  44. use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
  45. use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
  46. use Symfony\Component\Serializer\Serializer;
  47. use \DrewM\MailChimp\MailChimp;
  48. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  49. use Twig\Environment;
  50. use Twig\Extension\AbstractExtension;
  51. use Twig\Loader\FilesystemLoader;
  52. use Twig\TwigFunction;
  53. use Vich\UploaderBundle\Templating\Helper\UploaderHelper;
  54. class AppService extends AbstractExtension
  55. {
  56.     protected $entityManager;
  57.     protected $router;
  58.     protected $logger;
  59.     protected $security;
  60.     protected $requestStack;
  61.     protected $mailer;
  62.     protected $mailer_user;
  63.     protected $mailer_dsn;
  64.     protected $parameterBag;
  65.     private $translator;
  66.     public function __construct(RequestStack $requestStackSecurity $securityTranslatorInterface $translatorEntityManagerInterface $entityManagerUrlGeneratorInterface $routerLoggerInterface $logger$mailer_userMailerInterface $mailer$mailer_dsnParameterBagInterface $parameterBagUploaderHelper $helper)
  67.     {
  68.         $this->em $entityManager;
  69.         $this->logger $logger;
  70.         $this->router $router;
  71.         $this->translator $translator;
  72.         $this->security $security;
  73.         $this->requestStack $requestStack;
  74.         $this->mailer_user $mailer_user;
  75.         $this->mailer $mailer;
  76.         $this->mailer_dsn $mailer_dsn;
  77.         $this->parameterBag $parameterBag;
  78.         $this->helper $helper;
  79.     }
  80.     public function getFunctions(): array
  81.     {
  82.         return [
  83.             new TwigFunction('getFormattedDate', [$this'getFormattedDate']),
  84.             new TwigFunction('getPage', [$this'getPage']),
  85.             new TwigFunction('getLinksNav', [$this'getLinksNav']),
  86.             new TwigFunction('getLinksFooter', [$this'getLinksFooter']),
  87.             new TwigFunction('getHistories', [$this'getHistories']),
  88.             new TwigFunction('getProjectsMap', [$this'getProjectsMap']),
  89.             new TwigFunction('getLandingSliders', [$this'getLandingSliders']),
  90.             new TwigFunction('getSubCategories', [$this'getSubCategories']),
  91.             new TwigFunction('getCategories', [$this'getCategories']),
  92.             new TwigFunction('getSitemapLinks', [$this'getSitemapLinks']),
  93.             new TwigFunction('strEndsWith', [$this'strEndsWith']),
  94.             new TwigFunction('getApplicationsBloc', [$this'getApplicationsBloc']),
  95.             new TwigFunction('getPropTrans', [$this'getPropTrans']),
  96.             new TwigFunction('isCrudTextEditor', [$this'isCrudTextEditor']),
  97.             new TwigFunction('getProducts', [$this'getProducts']),
  98.             new TwigFunction('getProductUrl', [$this'getProductUrl']),
  99.             new TwigFunction('getProductPhaseEvolutions', [$this'getProductPhaseEvolutions']),
  100.             new TwigFunction('getProductParagraphs', [$this'getProductParagraphs']),
  101.             new TwigFunction('getProductKeyFeatures', [$this'getProductKeyFeatures']),
  102.             new TwigFunction('getProductSoftwareProductAddons', [$this'getProductSoftwareProductAddons']),
  103.             new TwigFunction('getProductHardwareProductAddons', [$this'getProductHardwareProductAddons']),
  104.             new TwigFunction('getProductBrochurePdf', [$this'getProductBrochurePdf']),
  105.             new TwigFunction('getProductProductBrochures', [$this'getProductProductBrochures']),
  106.             new TwigFunction('getProductPublications', [$this'getProductPublications']),
  107.             new TwigFunction('getProductProductMedias', [$this'getProductProductMedias']),
  108.             new TwigFunction('getProductProducts', [$this'getProductProducts']),
  109.             new TwigFunction('getSubCategoryParagraphs', [$this'getSubCategoryParagraphs']),
  110.             new TwigFunction('getSubCategoryProducts', [$this'getSubCategoryProducts']),
  111.             new TwigFunction('getPublicationPhaseEvolutions', [$this'getPublicationPhaseEvolutions']),
  112.             new TwigFunction('getPhaseEvolutionFile', [$this'getPhaseEvolutionFile']),
  113.             new TwigFunction('getPresentationBloc', [$this'getPresentationBloc']),
  114.             new TwigFunction('getLandingPageParagraphs', [$this'getLandingPageParagraphs']),
  115.         ];
  116.     }
  117.     public function getPhaseEvolutionFile(PhaseEvolution $phaseEvolutionProduct $product nullCategory $category null)
  118.     {
  119.         if ($phaseEvolution->getCategoryIcon()) {
  120.             if ($product) {
  121.                 $subCategory $product->getProductSubCategories()->first() ? $product->getProductSubCategories()->first()->getSubCategory() : null;
  122.                 $category $subCategory $subCategory->getCategory() : null;
  123.             }
  124.             if ($category and $category->getCategoryIconFileName()) {
  125.                 return "/" $this->helper->asset($category'categoryIconFile');
  126.             }
  127.         } else {
  128.             return "/" $this->helper->asset($phaseEvolution'phaseEvolutionFile');
  129.         }
  130.         return null;
  131.     }
  132.     public function getSubCategoryProducts(SubCategory $subCategory$isHardware null)
  133.     {
  134.         $products = [];
  135.         $repoProductSubCategory $this->em->getRepository(ProductSubCategory::class);
  136.         $productSubCategories $repoProductSubCategory->findBy(["subCategory" => $subCategory], ["position" => "asc"]);
  137.         foreach ($productSubCategories as $key => $productSubCategory) {
  138.             $product $productSubCategory->getProduct();
  139.             if ($product and !$product->getHide() and (is_null($isHardware) or ($isHardware and $product->getIsHardware()) or (!$isHardware and !$product->getIsHardware()))) {
  140.                 $products[] = $product;
  141.             }
  142.         }
  143.         return $products;
  144.     }
  145.     public function getRoutesControllers()
  146.     {
  147.         $routes $this->getRoutes();
  148.         $controllers = [];
  149. //        $controllers["Aucun"] = null;
  150.         foreach ($routes as $key => $route) {
  151.             $controllers[$route->getPath()] = $route->getDefault('_controller');
  152.         }
  153.         return $controllers;
  154.     }
  155.     public function getPage($controller)
  156.     {
  157.         $repoPage $this->em->getRepository(Page::class);
  158.         $page $repoPage->findOneBy(["controller" => $controller]);
  159.         return $page;
  160.     }
  161.     public function getRoute($controller)
  162.     {
  163.         $routes $this->getRoutes();
  164.         foreach ($routes as $key => $route) {
  165.             if ($route->getDefault('_controller') == $controller) {
  166.                 return $route;
  167.             }
  168.         }
  169.         return null;
  170.     }
  171.     public function getRoutes()
  172.     {
  173.         $router $this->router;
  174.         $routes $router->getRouteCollection()->all();
  175.         foreach ($routes as $key => $route) {
  176.             if (strpos($route->getDefault('_controller'), "App\Controller") === false) {
  177.                 unset($routes[$key]);
  178.             }
  179.         }
  180.         return $routes;
  181.     }
  182.     public function getLandingSliders()
  183.     {
  184.         $repoLandingSlider $this->em->getRepository(LandingSlider::class);
  185.         return $repoLandingSlider->findBy([], ["position" => "asc"]);
  186.     }
  187.     public function getProjectsMap($format null$data = [])
  188.     {
  189.         $encoders = [new XmlEncoder(), new JsonEncoder()];
  190.         $normalizers = [new ProjectNormalizer(new ObjectNormalizer())];
  191. //        $normalizers = [new ObjectNormalizer()];
  192.         $serializer = new Serializer($normalizers$encoders);
  193.         $repoProject $this->em->getRepository(Project::class);
  194.         $projects $repoProject->search($data);
  195.         return $format == "json" $serializer->serialize($projects'json', [AbstractNormalizer::ATTRIBUTES => ['latitude''longitude''id''title']]) : $projects;
  196.     }
  197.     public function suscribeToList($email)
  198.     {
  199.         try {
  200.             $MailChimp = new MailChimp('api_key');
  201. //            dump($MailChimp->get('lists'));
  202. //            exit;
  203.             // prendre l'id de la liste et non le webId
  204.             $list_id "list_id";
  205.             $result $MailChimp->post("lists/$list_id/members", [
  206.                 'email_address' => $email,
  207.                 'status' => 'subscribed',
  208.             ]);
  209.         } catch (\Exception $e) {
  210.         }
  211.     }
  212.     public function getPropertyInfo()
  213.     {
  214.         $phpDocExtractor = new PhpDocExtractor();
  215.         $reflectionExtractor = new ReflectionExtractor();
  216.         $listExtractors = [$reflectionExtractor];
  217.         $typeExtractors = [$phpDocExtractor$reflectionExtractor];
  218.         return new PropertyInfoExtractor(
  219.             $listExtractors,
  220.             $typeExtractors
  221.         );
  222.     }
  223.     public function isCrudTextEditor($name)
  224.     {
  225.         $arr = [
  226.             "description",
  227.             "intro",
  228.             "content",
  229.         ];
  230.         foreach ($arr as $key => $haystack) {
  231.             if (str_contains($haystack$name)) {
  232.                 return true;
  233.             }
  234.         }
  235.         return false;
  236.     }
  237.     public function getCrudProps($namespace)
  238.     {
  239.         $propertyInfo $this->getPropertyInfo();
  240.         $properties = ($propertyInfo->getProperties($namespace) ?? []);
  241.         $props = [];
  242.         $noProp = ["currentLocale""defaultLocale""translatable""locale""empty""id"];
  243.         foreach ($properties as $key => $value) {
  244.             $propertyType $propertyInfo->getTypes($namespace$value)[0];
  245.             if (!in_array($value$noProp) and !str_ends_with($value"FileSize") and !str_ends_with($value"FileUpdatedAt")
  246.                 and !str_contains($value"FileName") and !$propertyType->isCollection()) {
  247.                 $type = ($propertyType->getClassName() ? "ManyToOne" $propertyType->getBuiltinType());
  248.                 $props[] = [
  249.                     "name" => $value,
  250.                     "type" => $type
  251.                 ];
  252.             }
  253.         }
  254.         return $props;
  255.     }
  256.     public function getProductUrl(Product $productSubCategory $subCategory null)
  257.     {
  258.         $subCategory $subCategory ?? ($product->getProductSubCategories()->first() ? $product->getProductSubCategories()->first()->getSubCategory() : null);
  259.         if (!$subCategory) {
  260.             return "#";
  261.         }
  262.         $category $subCategory->getCategory();
  263.         return $this->router->generate("front_product", ["catSlug" => $category->getSlug(), "subCatSlug" => $subCategory->getSlug(), "slug" => $product->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  264.     }
  265.     public function getPropField($type)
  266.     {
  267.         return "Field";
  268.     }
  269.     public function getSubCategories($categoryId$exceptId null)
  270.     {
  271.         $repoSubCategory $this->em->getRepository(SubCategory::class);
  272.         $data = [
  273.             "category" => $categoryId,
  274.             "hide" => false,
  275.             "orderBys" => ["a.position" => "asc"]
  276.         ];
  277.         if ($exceptId) {
  278.             $data["different"] = ["a.id" => $exceptId];
  279.         }
  280.         return $repoSubCategory->search($data);
  281.     }
  282.     public function getProductParagraphs(Product $product)
  283.     {
  284.         $repoProductParagraph $this->em->getRepository(ProductParagraph::class);
  285.         $productParagraphs $repoProductParagraph->findBy(["product" => $product], ["position" => "asc"]);
  286.         return $productParagraphs;
  287.     }
  288.     public function getLandingPageParagraphs(LandingPage $landingPage)
  289.     {
  290.         $repoProductParagraph $this->em->getRepository(ProductParagraph::class);
  291.         $productParagraphs $repoProductParagraph->findBy(["landingPage" => $landingPage], ["position" => "asc"]);
  292.         return $productParagraphs;
  293.     }
  294.     public function getSubCategoryParagraphs(SubCategory $subCategory)
  295.     {
  296.         $repoSubCategoryParagraph $this->em->getRepository(ProductParagraph::class);
  297.         $subCategoryParagraphs $repoSubCategoryParagraph->findBy(["subCategory" => $subCategory], ["position" => "asc"]);
  298.         return $subCategoryParagraphs;
  299.     }
  300.     public function getProductHardwareProductAddons(Product $product)
  301.     {
  302.         $repoProductHardwareProductAddon $this->em->getRepository(ProductHardwareProductAddon::class);
  303.         $productHardwareProductAddons $repoProductHardwareProductAddon->findBy(["product" => $product], ["position" => "asc"]);
  304.         return $productHardwareProductAddons;
  305.     }
  306.     public function getProductProductBrochures(Product $product)
  307.     {
  308.         $repoProductProductBrochure $this->em->getRepository(ProductProductBrochure::class);
  309.         $productProductBrochures $repoProductProductBrochure->findBy(["product" => $product], ["position" => "asc"]);
  310.         return $productProductBrochures;
  311.     }
  312.     public function getProductProductMedias(Product $product)
  313.     {
  314.         $repoProductProductMedia $this->em->getRepository(ProductProductMedia::class);
  315.         $productProductMedias $repoProductProductMedia->findBy(["product" => $product], ["position" => "asc"]);
  316.         return $productProductMedias;
  317.     }
  318.     public function getProductProducts(Product $product)
  319.     {
  320.         $repoProductProduct $this->em->getRepository(ProductProduct::class);
  321.         $productProducts $repoProductProduct->findBy(["product" => $product], ["position" => "asc"]);
  322.         $products = [];
  323.         foreach ($productProducts as $key => $productProduct) {
  324.             if ($productProduct->getRelatedProduct()) {
  325.                 $products[] = $productProduct->getRelatedProduct();
  326.             }
  327.         }
  328.         return $products;
  329.     }
  330.     public function getProductPublications(Product $product)
  331.     {
  332.         $repoProductPublication $this->em->getRepository(ProductPublication::class);
  333.         $productPublications $repoProductPublication->findBy(["product" => $product], ["position" => "asc"]);
  334.         return $productPublications;
  335.     }
  336.     public function getProductBrochurePdf(ProductBrochure $productBrochure)
  337.     {
  338.         $locale $this->requestStack->getCurrentRequest()->getLocale();
  339.         $repoProductBrochurePdf $this->em->getRepository(ProductBrochurePdf::class);
  340.         $productBrochurePdf $repoProductBrochurePdf->findOneBy(["locale" => $locale"productBrochure" => $productBrochure]);
  341.         if (!$productBrochurePdf and $locale != "en") {
  342.             $productBrochurePdf $repoProductBrochurePdf->findOneBy(["locale" => "en""productBrochure" => $productBrochure]);
  343.         }
  344.         return $productBrochurePdf;
  345.     }
  346.     public function getProductSoftwareProductAddons(Product $product)
  347.     {
  348.         $repoProductSoftwareProductAddon $this->em->getRepository(ProductSoftwareProductAddon::class);
  349.         $productSoftwareProductAddons $repoProductSoftwareProductAddon->findBy(["product" => $product], ["position" => "asc"]);
  350.         return $productSoftwareProductAddons;
  351.     }
  352.     public function getProductKeyFeatures(Product $product)
  353.     {
  354.         $repoProductKeyFeature $this->em->getRepository(ProductKeyFeature::class);
  355.         $productKeyFeatures $repoProductKeyFeature->findBy(["product" => $product], ["position" => "asc"]);
  356.         return $productKeyFeatures;
  357.     }
  358.     public function getProductPhaseEvolutions(Product $product)
  359.     {
  360.         $repoPhaseEvolution $this->em->getRepository(PhaseEvolution::class);
  361.         $phaseEvolutions $repoPhaseEvolution->search(["product" => $product"orderBy" => ["a.position""asc"]]);
  362.         return $phaseEvolutions;
  363.     }
  364.     public function getProducts(SubCategory $subCategory)
  365.     {
  366.         $repoProductSubCategory $this->em->getRepository(ProductSubCategory::class);
  367.         $productSubCategories $repoProductSubCategory->findBy(["subCategory" => $subCategory], ["position" => "asc"]);
  368.         $products = [];
  369.         foreach ($productSubCategories as $key => $productSubCategory) {
  370.             if ($productSubCategory->getProduct() and !$productSubCategory->getProduct()->getHide()) {
  371.                 $products[] = $productSubCategory->getProduct();
  372.             }
  373.         }
  374.         return $products;
  375.     }
  376.     public function getCategories()
  377.     {
  378.         $repoCategory $this->em->getRepository(Category::class);
  379.         return $repoCategory->findBy([], ["position" => "asc"]);
  380.     }
  381.     public function getHistories()
  382.     {
  383.         $repoHistory $this->em->getRepository(History::class);
  384.         return $repoHistory->findBy([], ["year" => "asc"]);
  385.     }
  386.     public function getFormattedDate(\DateTime $dateTime$days true)
  387.     {
  388.         $translatedDays = [
  389.             => "Lundi",
  390.             => "Mardi",
  391.             => "Mercredi",
  392.             => "Jeudi",
  393.             => "Vendredi",
  394.             => "Samedi",
  395.             => "Dimanche",
  396.         ];
  397.         $translatedMonths = [
  398.             => "Janvier",
  399.             => "Février",
  400.             => "Mars",
  401.             => "Avril",
  402.             => "Mai",
  403.             => "Juin",
  404.             => "Juillet",
  405.             => "Août",
  406.             => "Septembre",
  407.             10 => "Octobre",
  408.             11 => "Novembre",
  409.             12 => "Décembre"
  410.         ];
  411.         return (($days ? ($translatedDays[$dateTime->format("N")] . " ") : "") . $dateTime->format("j") . " " $translatedMonths[$dateTime->format("n")] . " " $dateTime->format("Y"));
  412.     }
  413.     public function getPropTrans($name)
  414.     {
  415.         if ($name == "name") {
  416.             return "Nom";
  417.         } else if ($name == "firstname") {
  418.             return "Prénom";
  419.         } else if ($name == "lastname") {
  420.             return "Nom";
  421.         } else if ($name == "zipCode") {
  422.             return "Code postal";
  423.         } else if ($name == "address") {
  424.             return "Adresse";
  425.         } else if ($name == "city") {
  426.             return "Ville";
  427.         } else if ($name == "title") {
  428.             return "Titre";
  429.         } else if ($name == "category") {
  430.             return "Catégorie";
  431.         } else if ($name == "subCategory") {
  432.             return "Sous-catégorie";
  433.         } else if ($name == "subSubCategory") {
  434.             return "Sous-sous-catégorie";
  435.         } else if ($name == "color") {
  436.             return "Couleur";
  437.         } else if ($name == "content") {
  438.             return "Contenu";
  439.         } else if ($name == "metaTitle") {
  440.             return "Balise titre";
  441.         } else if ($name == "metaDescription") {
  442.             return "Balise description";
  443.         } else if ($name == "paragraphs") {
  444.             return "Paragraphe";
  445.         } else if ($name == "isDeleted") {
  446.             return "Supprimer";
  447.         } else if ($name == "link") {
  448.             return "Lien";
  449.         } else if ($name == "legend") {
  450.             return "Légende";
  451.         } else if ($name == "jobFunction") {
  452.             return "Fonction";
  453.         } else if ($name == "phoneNumber") {
  454.             return "Téléphone";
  455.         } else if ($name == "email") {
  456.             return "Adresse email";
  457.         } else if ($name == "subtitle" or $name == "Subtitle") {
  458.             return "Sous-titre";
  459.         } else if ($name == "createdAt") {
  460.             return "Date de création";
  461.         } else if ($name == "date") {
  462.             return "Date";
  463.         } else if ($name == "product") {
  464.             return "Produit";
  465.         }
  466.         return ucfirst($name);
  467.     }
  468.     public function getSitemapLinks()
  469.     {
  470.         $links = [
  471.             $this->router->generate('front_landing', [], UrlGeneratorInterface::ABSOLUTE_URL),
  472.             $this->router->generate('front_contact', [], UrlGeneratorInterface::ABSOLUTE_URL),
  473.             $this->router->generate('front_posts', [], UrlGeneratorInterface::ABSOLUTE_URL),
  474.             $this->router->generate('front_presentation', [], UrlGeneratorInterface::ABSOLUTE_URL),
  475.             $this->router->generate('front_support', [], UrlGeneratorInterface::ABSOLUTE_URL),
  476.         ];
  477.         $repoPost $this->em->getRepository(Post::class);
  478.         foreach ($repoPost->findAll() as $key => $post) {
  479.             $links[] = $this->router->generate('front_post', ["slug" => $post->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  480.         }
  481.         $repoLandingPage $this->em->getRepository(LandingPage::class);
  482.         foreach ($repoLandingPage->findAll() as $key => $landingPage) {
  483.             $links[] = $this->router->generate('front_landing_page', ["slug" => $landingPage->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  484.         }
  485.         $repoProduct $this->em->getRepository(Product::class);
  486.         foreach ($repoProduct->findBy(["hide" => false]) as $key => $product) {
  487.             $links[] = $this->getProductUrl($product);
  488.         }
  489.         $repoSubCategory $this->em->getRepository(SubCategory::class);
  490.         foreach ($repoSubCategory->findBy(["hide" => false]) as $key => $subCategory) {
  491.             $links[] = $this->router->generate('front_sub_category', ["slug" => $subCategory->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  492.         }
  493.         $repoCategory $this->em->getRepository(Category::class);
  494.         foreach ($repoCategory->findAll() as $key => $category) {
  495.             $links[] = $this->router->generate('front_products', ["catSlug" => $category->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  496.             $links[] = $this->router->generate('front_publications', ["slug" => $category->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
  497.         }
  498.         return $links;
  499.     }
  500.     public function getPublicationPhaseEvolutions(Publication $publication)
  501.     {
  502.         $phaseEvolutions = new ArrayCollection();
  503.         foreach ($publication->getProductPublications() as $key => $productPublication) {
  504.             $product $productPublication->getProduct();
  505.             foreach ($product->getPhaseEvolutions() as $key => $phaseEvolution) {
  506.                 if (!$phaseEvolutions->contains($phaseEvolution)) {
  507.                     $phaseEvolutions->add($phaseEvolution);
  508.                 }
  509.             }
  510.         }
  511.         return $phaseEvolutions;
  512.     }
  513.     public function strEndsWith($haystack$needle)
  514.     {
  515.         return str_ends_with($haystack$needle);
  516.     }
  517.     public function getLinksNav()
  518.     {
  519. //        $products= $this->appService->getProductsCatalogue();
  520. //        foreach ($products as $key => $product){
  521. //            $skillLinks[$skill->getTitle()]=$this->router->generate('front_product',["slug"=>$product->getSlug()]);
  522. //        }
  523.         return [
  524.             ($this->translator->trans("navbar.home")) => $this->router->generate('front_landing'),
  525.             ($this->translator->trans("navbar.products")) => "#",
  526.             ($this->translator->trans("navbar.about")) => $this->router->generate('front_presentation'),
  527.             $this->translator->trans("navbar.publications") => "#",
  528. //            ($this->translator->trans("navbar.distributeurs")) => $this->router->generate('ront_distributeurs'),
  529.             ($this->translator->trans("navbar.posts")) => $this->router->generate('front_posts'),
  530. //            ($this->translator->trans("navbar.contact")) => $this->router->generate('front_contact'),
  531.             ($this->translator->trans("navbar.support")) => $this->router->generate('front_support'),
  532. //            "Contact" => $this->router->generate('front_contact'),
  533.         ];
  534.     }
  535.     public function getLinksFooter()
  536.     {
  537.         return [
  538.             $this->translator->trans("footer.about") => $this->router->generate('front_presentation'),
  539.             $this->translator->trans("footer.blog") => $this->router->generate('front_posts'),
  540. //            $this->translator->trans("footer.distributeur") => $this->router->generate('front_distributeurs'),
  541.             $this->translator->trans("footer.support") => $this->router->generate('front_support'),
  542.             $this->translator->trans("footer.contact") => $this->router->generate('front_contact'),
  543.         ];
  544.     }
  545.     public function getApplicationsBloc()
  546.     {
  547.         return [
  548.             $this->translator->trans("application.sticky.about") => "#presentation2",
  549.             $this->translator->trans("application.sticky.hardware") => "#hardwareProductsApp",
  550.             $this->translator->trans("application.sticky.software") => "#softwareProductsApp",
  551.             $this->translator->trans("application.sticky.applications") => "#relatedApp",
  552.         ];
  553.     }
  554.     public function getPresentationBloc()
  555.     {
  556.         return [
  557.             $this->translator->trans("presentation.sticky.histories") => "#histories",
  558.             $this->translator->trans("presentation.sticky.values") => "#values",
  559.             $this->translator->trans("presentation.sticky.team") => "#team",
  560.             $this->translator->trans("presentation.sticky.partners") => "#partners",
  561.             $this->translator->trans("presentation.sticky.distributors") => "#distributors",
  562.             $this->translator->trans("presentation.sticky.world") => "#world",
  563.             $this->translator->trans("presentation.sticky.iso") => "#iso",
  564.             $this->translator->trans("presentation.sticky.join") => "#joinUs",
  565.         ];
  566.     }
  567. }