src/Controller/ArticleController.php line 40

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Article;
  4. use App\Entity\ArticleView;
  5. use App\Entity\Comment;
  6. use App\Form\AddCommentMobileType;
  7. use App\Security\LoginFormAuthenticator;
  8. use App\Service\ArticleBlockEntityService;
  9. use App\Service\ArticleEntityService;
  10. use App\Service\MediaEntityService;
  11. use App\Service\PlatformService;
  12. use App\Service\StripeService;
  13. use App\Service\UserEntityService;
  14. use Bluesquare\ValidatorBundle\Validator;
  15. use Doctrine\ORM\EntityManagerInterface;
  16. use Dompdf\Dompdf;
  17. use Dompdf\Options;
  18. use EWZ\Bundle\RecaptchaBundle\Form\Type\EWZRecaptchaV3Type;
  19. use EWZ\Bundle\RecaptchaBundle\Validator\Constraints\IsTrueV3;
  20. use Knp\Component\Pager\Pagination\PaginationInterface;
  21. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  22. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  23. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  24. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  25. use Symfony\Component\Form\Extension\Core\Type\TextType;
  26. use Symfony\Component\HttpFoundation\Request;
  27. use Symfony\Component\HttpFoundation\Response;
  28. use Symfony\Component\Routing\Annotation\Route;
  29. use Symfony\Component\Validator\Constraints\Email;
  30. use Symfony\Component\Validator\Constraints\NotBlank;
  31. use Symfony\Component\Validator\Constraints\Required;
  32. class ArticleController extends AbstractController
  33. {
  34.     /**
  35.      * @Route("/article/{slug}-{id}", name="article.view", requirements={"slug"="[a-zA-Z0-9-]+", "id"="\d+"})
  36.      */
  37.     public function view(ArticleEntityService $articleServiceValidator $validatorArticleBlockEntityService $blockServiceMediaEntityService $mediaEntityServiceEntityManagerInterface $manager$slug$idRequest $requestPlatformService $platformServiceUserEntityService $userEntityServiceStripeService $stripeService)
  38.     {
  39.         $user $this->getUser();
  40.         $article $articleService->getFront($id);
  41.         if(!$article){
  42.             return $this->redirectToRoute('homepage');
  43.         }
  44.         if (!$article || !($article instanceof Article)) {
  45.             throw $this->createNotFoundException();
  46.         }
  47.         if ($slug !== $article->getSlug()) {
  48.             return $this->redirectToRoute('article.view', ['slug' => $article->getSlug(), 'id' => $article->getId()]);
  49.         }
  50.         $cover $article->getCover() ? $mediaEntityService->format($article->getCover()) : null;
  51.         // TODO: uncomment si besoin de n'autoriser l'accès qu'aux articles en ligne via l'url directe
  52.         // if ($article->getPublicationStatus() !== Article::PUBLICATION_STATUS_PUBLISHED)
  53.         //    throw $this->createNotFoundException();
  54.         $now = new \DateTime();
  55.         // if (!is_null($article->getPublicationEnd()) && $article->getPublicationEnd() < $now)
  56.         //    throw $this->createNotFoundException();
  57.         // if (!is_null($article->getPublicationStart()) && $article->getPublicationStart() > $now)
  58.         //    throw $this->createNotFoundException();
  59.         // Breadcrumb
  60.         $breadcrumb = [];
  61.         // $breadcrumb[getenv('APP_NAME')] = $this->generateUrl('home');
  62.         $categories = [];
  63.         $category null;
  64.         if (\count($article->getArticleCategories()) > 0) {
  65.             $category $article->getArticleCategories()[0]->getCategory();
  66.         }
  67.         while (null !== $category) {
  68.             $categories[] = $category;
  69.             $category $category->getParent();
  70.         }
  71.         $categories array_reverse($categories);
  72.         foreach ($categories as $category) {
  73.             $breadcrumb[$category->getName()] = $this->generateUrl('category.view', ['slug' => $category->getSlug()]);
  74.         }
  75.         $breadcrumb[$article->getTitle()] = $this->generateUrl('article.view', ['slug' => $article->getSlug(), 'id' => $article->getId()]);
  76.         // Tags
  77.         $tags = [];
  78.         foreach ($article->getArticleTags() as $articleTag) {
  79.             $tags[] = $articleTag->getTag();
  80.         }
  81.         // Blocks
  82.         $blocks $blockService->index($article);
  83.         usort($blocks, function ($a$b) {
  84.             return $a['position'] - $b['position'];
  85.         });
  86.         $blocks array_map(function ($block) {
  87.             $block['data'] = @json_decode($block['data'], true);
  88.             if (!\is_array($block['data'])) {
  89.                 $block['data'] = [];
  90.             }
  91.             return $block;
  92.         }, $blocks);
  93.         // Comments
  94.         $comments $manager->getRepository(Comment::class)->findBy(['article' => $article'parent' => null'deleted_at' => null], ['created_at' => 'ASC']);
  95.         $articleRepository $manager->getRepository(Article::class);
  96.         $live $articleService->formatAll($articleRepository->getLiveArticles(null4)); // TODO: channel
  97.         $ip $request->getClientIp();
  98.         $user_agents $request->server->get('HTTP_USER_AGENT');
  99.         $identifier md5($ip.$user_agents);
  100.         $articleViewRepository $this->getDoctrine()->getRepository(ArticleView::class);
  101.         $articleViewVisited $articleViewRepository->findIfVisitedToday($identifier$article);
  102.         if (!$articleViewVisited) { // The user hasn't already visited the article today
  103.             $now = new \DateTime();
  104.             $articleView = new ArticleView();
  105.             $articleView->setVisitedAt($now);
  106.             $articleView->setUser($user);
  107.             $articleView->setArticle($article);
  108.             $articleView->setIdentifier($identifier);
  109.             // TODO: uncomment si le log des visites web sont souhaitées
  110.             // $em = $this->getDoctrine()->getManager();
  111.             // $em->persist($articleView);
  112.             // $em->flush();
  113.         }
  114.         // Check that the user has subscribed in zenabo or stripe product --------------
  115.         $user_is_premium false;
  116.         $article_products $article->getArticleProducts();
  117.         foreach ($article_products as $articleProduct) {
  118.             if (
  119.                 $user &&
  120.                 ($stripeService->userSubscribedToProduct($user$articleProduct->getProductStripeId()) ||
  121.                     $stripeService->userBoughtProductOneShot($user$articleProduct->getProductStripeId()))
  122.             ) {
  123.                 $user_is_premium true;
  124.                 break;
  125.             }
  126.         }
  127.         // LOANN => I commented this because the migration Zenabo -> A&C has been done
  128. //        if ($user && !$user_is_premium && ($userEntityService->isZenaboPremium($user))) {
  129. //            $user_is_premium = true;
  130. //        }
  131.         // -----------------------------------------------------------------------------
  132.         $comment = new Comment();
  133.         $user $this->getUser();
  134.         $builder $this->createFormBuilder($comment)
  135.             ->add('parent'HiddenType::class, [
  136.                 'mapped' => false,
  137.             ])
  138.             ->add('content'TextType::class, [
  139.                 'constraints' => [
  140.                     new NotBlank(),
  141.                 ],
  142.             ])
  143.             ->add('recaptcha'EWZRecaptchaV3Type::class, [
  144.                 'action_name' => 'add_comment_'.$article->getId(),
  145.                 'mapped' => false,
  146.                 'constraints' => [
  147.                     new IsTrueV3(),
  148.                 ],
  149.             ]);
  150.         if (!$user) {
  151.             $builder
  152.                 ->add('author_name'TextType::class, [
  153.                     'constraints' => [
  154.                         new Required(),
  155.                         new NotBlank(),
  156.                     ],
  157.                 ])
  158.                 ->add('author_email'EmailType::class, [
  159.                     'constraints' => [
  160.                         new Required(),
  161.                         new Email(),
  162.                     ],
  163.                 ]);
  164.         }
  165.         $addCommentForm $builder->getForm();
  166.         $addCommentForm->handleRequest($request);
  167.         if ($addCommentForm->isSubmitted() && $addCommentForm->isValid()) {
  168.             $comment->setArticle($article);
  169.             if ($user) {
  170.                 $comment->setUser($user);
  171.             }
  172.             $parentId $addCommentForm->get('parent')->getData();
  173.             if ($parentId) {
  174.                 $parent $manager->getRepository(Comment::class)->find($parentId);
  175.                 if ($parent && $parent->getArticle() === $article && null === $parent->getParent()) {
  176.                     $comment->setParent($parent);
  177.                 }
  178.             }
  179.             $manager->persist($comment);
  180.             $manager->flush();
  181.             $url $this->generateUrl('article.view', ['slug' => $article->getSlug(), 'id' => $article->getId()]);
  182.             return $this->redirect($url.'#comment-'.$comment->getId());
  183.         }
  184.         $commentM = new Comment();
  185.         $addCommentFormMobile $this->createForm(AddCommentMobileType::class, $commentM);
  186.         $addCommentFormMobile->handleRequest($request);
  187.         if ($addCommentFormMobile->isSubmitted() && $addCommentFormMobile->isValid()) {
  188.             $commentM->setArticle($article);
  189.             if ($user) {
  190.                 $commentM->setUser($user);
  191.                 $commentM->setArticle($article);
  192.                 $commentM->setContent($addCommentFormMobile->get('content')->getData());
  193.                 $manager->persist($commentM);
  194.                 $manager->flush();
  195.             }
  196.             $url $this->generateUrl('article.view', ['slug' => $article->getSlug(), 'id' => $article->getId()]);
  197.             return $this->redirect($url.'#comment-'.$comment->getId());
  198.         }
  199.         $author $articleService->getAuthorEntity($article);
  200.         $authorAvatar $author && $author->getAvatar() ? $mediaEntityService->format($author->getAvatar()) : null;
  201.         $user_subscriptions $user $stripeService->getUserSubscriptions($this->getUser()) : [];
  202.         $subscription_status false;
  203.         $status=['active','trialing'];
  204.         if (!empty($user_subscriptions)) {
  205.             foreach ($user_subscriptions as $user_subscription) {
  206.                 if (in_array(strtolower($user_subscription->getStatus()), $status)) {
  207.                     $subscription_status true;
  208.                 }
  209.             }
  210.         }
  211.         return $this->render('article/article.html.twig', [
  212.             'author' => $author,
  213.             'article' => $article,
  214.             'article_formatted' => $articleService->format($articletrue),
  215.             'breadcrumb' => $breadcrumb,
  216.             'tags' => $tags,
  217.             'blocks' => $blocks,
  218.             'comments' => $comments,
  219.             'cover' => $cover,
  220.             'live' => $live,
  221.             'add_comment_form' => $addCommentForm->createView(),
  222.             'add_comment_form_mobile' => $addCommentFormMobile->createView(),
  223.             'validator' => $validator,
  224.             'user_is_digital_premium' => $user_is_premium,
  225.             'e_shop_url_product' => $article->getEshopUrlProduct() ? $article->getEshopUrlProduct() : $stripeService->generateEshopUrl($article),
  226.             'e_shop_url_product_sub' => $article->getEshopUrlProductSub() ? $article->getEshopUrlProductSub() : $stripeService->generateEshopUrl($article'recurring'),
  227.             'userSubscriptionsStatus' => $subscription_status,
  228.             'authenticate_user' => $user,
  229.             'authorAvatar' => $authorAvatar,
  230.         ]);
  231.     }
  232.     /**
  233.      * @Route("/pave-pub", name="pave.pub")
  234.      * @Cache(smaxage="3600", public=true)
  235.      */
  236.     public function renderPubPave(StripeService $stripeService)
  237.     {
  238.         $user $this->getUser();
  239.         $user_subscriptions $user $stripeService->getUserSubscriptions($this->getUser()) : [];
  240.         $subscription_status false;
  241.         if (!empty($user_subscriptions)) {
  242.             foreach ($user_subscriptions as $user_subscription) {
  243.                 if ('active' === $user_subscription->getStatus()) {
  244.                     $subscription_status true;
  245.                 }
  246.             }
  247.         }
  248.         $html $this->render('article/pub.html.twig', [
  249.             'user' => $user,
  250.             'subscription_status' => $subscription_status,
  251.         ])->getContent();
  252.         return $this->json(['html' => $html], 200);
  253.     }
  254.     public static function convert_from_latin1_to_utf8_recursively($dat)
  255.     {
  256.         if (\is_string($dat)) {
  257.             return utf8_encode($dat);
  258.         } elseif (\is_array($dat)) {
  259.             $ret = [];
  260.             foreach ($dat as $i => $d) {
  261.                 $ret[$i] = self::convert_from_latin1_to_utf8_recursively($d);
  262.             }
  263.             return $ret;
  264.         } elseif (\is_object($dat)) {
  265.             foreach ($dat as $i => $d) {
  266.                 $dat->$i self::convert_from_latin1_to_utf8_recursively($d);
  267.             }
  268.             return $dat;
  269.         }
  270.         return $dat;
  271.     }
  272.     /**
  273.      * @Route("/article/{slug}-{id}/comment", name="article.comment", requirements={"slug"="[a-zA-Z0-9-]+", "id"="\d+"})
  274.      */
  275.     public function comment(Request $requestArticleEntityService $articleServiceValidator $validatorEntityManagerInterface $manager$slug$id)
  276.     {
  277.         $article $articleService->get($id);
  278.         if (!$article || !($article instanceof Article)) {
  279.             throw $this->createNotFoundException();
  280.         }
  281.         if ($validator->post()) {
  282.             if (null === $this->getUser()) {
  283.                 $validator->required('author_name''author_email');
  284.             }
  285.             $validator->required('content''_captcha''_captcha_verification');
  286.             if ($validator->check()) {
  287.                 $comment = new Comment();
  288.                 $validator->entity($comment);
  289.                 $validator->inject('content');
  290.                 $comment->setArticle($article);
  291.                 if (null === $this->getUser()) {
  292.                     $validator->inject('author_name''author_email');
  293.                 } else {
  294.                     $comment->setUser($this->getUser());
  295.                 }
  296.                 if ($validator->has('parent')) {
  297.                     $parent $manager->getRepository(Comment::class)->find($validator->get('parent'));
  298.                     if ($parent && $parent->getArticle() === $article && null === $parent->getParent()) {
  299.                         $comment->setParent($parent);
  300.                     }
  301.                 }
  302.                 $manager->persist($comment);
  303.                 $manager->flush();
  304.             } else {
  305.                 $validator->keep();
  306.             }
  307.         }
  308.         return $this->redirectToRoute('article.view', ['slug' => $article->getSlug(), 'id' => $article->getId()]);
  309.     }
  310.     /**
  311.      * @Route("/search", name="articles.search.view")
  312.      */
  313.     public function searchView(Request $request)
  314.     {
  315.         return $this->render('search/search.html.twig');
  316.     }
  317.     /**
  318.      * @Route("/articles/search", name="articles.search")
  319.      */
  320.     public function search(Request $requestArticleEntityService $articleEntityServiceEntityManagerInterface $manager)
  321.     {
  322.         $articleRepository $manager->getRepository(Article::class);
  323.         $search $request->get('search');
  324.         if (!$search) {
  325.             return $this->json([
  326.                 'error' => 'value.empty',
  327.                 'message' => 'Please write a value in search input',
  328.             ], 404);
  329.         }
  330.         if ($request->get('limit')) {
  331.             $limit $request->get('limit');
  332.         } else {
  333.             $limit 10;
  334.         }
  335.         $articlesObjects $articleRepository->findArticlesFromSearch($search'DESC'$limit);
  336.         $html '';
  337.         $articles $articleEntityService->formatAll($articlesObjects);
  338.         if (!empty($articles)) {
  339.             $html $this->renderView('search/_partials/articles.html.twig', [
  340.                 'articles' => $articles,
  341.             ]);
  342.         }
  343.         $count = \count($articles);
  344.         return $this->json(['html' => $html'count' => $count], 200);
  345.     }
  346.     /**
  347.      * @Route("/{slug}-{id}", name="article.legacy", requirements={"slug"="[a-zA-Z0-9-]+", "id"="\d+"})
  348.      */
  349.     public function legacy(ArticleEntityService $articleServiceArticleBlockEntityService $blockServiceMediaEntityService $mediaEntityServiceEntityManagerInterface $manager$slug$idRequest $request)
  350.     {
  351.         $article $manager->getRepository(Article::class)->findOneBy(['legacy_id' => $id]);
  352.         if (!$article) {
  353.             throw $this->createNotFoundException();
  354.         }
  355.         return $this->redirectToRoute('article.view', ['slug' => $article->getSlug(), 'id' => $article->getId()]);
  356.     }
  357.     /**
  358.      * @Route("/article/download_pdf/{id}", name="article.download_pdf", methods={"GET"})
  359.      */
  360.     public function downloadPdf($idArticleEntityService $entityServiceArticleBlockEntityService $blockEntityService)
  361.     {
  362.         $entity $entityService->get($id);
  363.         if (!$entity || !($entity instanceof Article)) {
  364.             throw $this->createNotFoundException();
  365.         }
  366.         // Blocks
  367.         $blocks $blockEntityService->index($entity);
  368.         usort($blocks, function ($a$b) {
  369.             return $a['position'] - $b['position'];
  370.         });
  371.         $blocks array_map(function ($block) {
  372.             $block['data'] = @json_decode($block['data'], true);
  373.             if (!\is_array($block['data'])) {
  374.                 $block['data'] = [];
  375.             }
  376.             return $block;
  377.         }, $blocks);
  378.         $options = new Options();
  379.         $options->set('isRemoteEnabled'true);
  380.         $options->set('isHtml5ParserEnabled'true);
  381.         setlocale(\LC_NUMERIC'C');
  382.         $dompdf = new Dompdf($options);
  383.         $html $this->renderView('article/article_pdf.html.twig', [
  384.             'article_formatted' => $entityService->format($entitytrue),
  385.             'article' => $entity,
  386.             'blocks' => $blocks,
  387.         ]);
  388.         iconv('latin5''utf-8'$html);
  389.         $dompdf->loadHtml($html);
  390.         $dompdf->render();
  391.         $dompdf->stream();
  392.         return new Response("");
  393.     }
  394.     private function getDeviceType(Request $request)
  395.     {
  396.         return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i",
  397.             $request->server->get('HTTP_USER_AGENT')) ? 'mobile' 'desktop';
  398.     }
  399.     /**
  400.      * @Route("/articleLive/{page}", name="articleLive", methods={"GET"},  defaults={"page"=1})
  401.      */
  402.     public function articleLive(Request $request$pageArticleEntityService $articleServiceEntityManagerInterface $manager)
  403.     {
  404.         $deviceType $this->getDeviceType($request);
  405.         $page = (int) $page;
  406.         $page max(1$page);
  407.         $paginationStep $deviceType === 'desktop' 10 4;
  408.         $maxResults $paginationStep $page;
  409.         /** @var PaginationInterface $pagination */
  410.         $pagination $manager->getRepository(Article::class)->getAllLiveArticles(1$maxResults);
  411.         $formattedArticles $articleService->formatAll($pagination->getItems());
  412.         $isLastPage $pagination->getTotalItemCount() <= $maxResults;
  413.         if ($request->isXmlHttpRequest()) {
  414.             return $this->render('themes/theme-5/article/articleLiveDetails.html.twig', [
  415.                 'live' => $formattedArticles,
  416.                 'isLastPage' => $isLastPage,
  417.                 'page' => $page,
  418.                 'deviceType' => $deviceType,
  419.             ]);
  420.         }
  421.         return $this->render('article/articleLive.html.twig', ['live' => $formattedArticles'isLastPage' => $isLastPage'page' => $page'deviceType' => $deviceType]);
  422.     }
  423.     /**
  424.      * @Route("/recent-comments", name="recent-comments", methods={"GET"})
  425.      */
  426.     public function recentComments(Request $requestEntityManagerInterface $manager)
  427.     {
  428.         $comments $manager->getRepository(Comment::class)->getLastComments();
  429.         $comment = new Comment();
  430.         $comment->setContent('ok');
  431.         return $this->render('_partials/comments/recent-comments.html.twig', [
  432.             'comments' => $comments,
  433.         ]);
  434.     }
  435.     /**
  436.      * @Route("/all-comments", name="all-comments", methods={"GET"})
  437.      */
  438.     public function AllComments(Request $requestEntityManagerInterface $manager)
  439.     {
  440.         $comments $manager->getRepository(Comment::class)->getLastComments();
  441.         return $this->render('_partials/comments/commentaires.html.twig', [
  442.             'comments' => $comments,
  443.         ]);
  444.     }
  445.     /**
  446.      * @Route("/add-comments/{commentObj}", name="add-comments", methods={"POST"})
  447.      */
  448.     public function add(Request $requestEntityManagerInterface $managerComment $commentObj)
  449.     {
  450.         $user $this->getUser();
  451.         $comment = new Comment();
  452.         $content $request->get('comment');
  453.         $article $commentObj->getArticle();
  454.         $comment->setArticle($article);
  455.         if ($user) {
  456.             $comment->setUser($user);
  457.             $article $commentObj->getArticle();
  458.             $comment->setArticle($article);
  459.             $comment->setContent($content);
  460.             $parentId $commentObj->getId();
  461.             if ($parentId) {
  462.                 $parent $manager->getRepository(Comment::class)->find($parentId);
  463.                 if ($parent && $parent->getArticle() === $article && null === $parent->getParent()) {
  464.                     $comment->setParent($parent);
  465.                 }
  466.             }
  467.             $manager->persist($comment);
  468.             $manager->flush();
  469.             $url $this->generateUrl('article.view', ['slug' => $article->getSlug(), 'id' => $article->getId()]);
  470.             return $this->redirect($url);
  471.         }
  472. //        $url = $this->generateUrl('homepage');
  473.         $url $this->generateUrl('article.view', ['slug' => $article->getSlug(), 'id' => $article->getId()]);
  474.         return $this->redirect($url);
  475.     }
  476.     /**
  477.      * @Route("/recherche", name="articles.recherche.view")
  478.      */
  479.     public function recherchView(Request $request)
  480.     {
  481.         return $this->render('search/search.html.twig');
  482.     }
  483.     /**
  484.      * @Route("/articles/recherche", name="articles.recherche")
  485.      */
  486.     public function recherche(Request $requestArticleEntityService $articleEntityService)
  487.     {
  488.         $articleRepository $this->getDoctrine()->getRepository(Article::class);
  489.         $search $request->get('search');
  490.         $fin $request->get('fin');
  491.         $debut $request->get('debut');
  492.         $order $request->get('order');
  493.         $isModal $request->get('isModal');
  494.         if ($request->get('limit')) {
  495.             $limit $request->get('limit');
  496.         } else {
  497.             $limit 10;
  498.         }
  499.         $click 0;
  500.         if (isset($isModal)) {
  501.             if (!empty($fin) && !empty($debut)) {
  502.                 $click $click 2;
  503.             } else {
  504.                 $click $click 1;
  505.             }
  506.         }
  507.         if (empty($fin) && empty($debut)) {
  508.             $count count($articleRepository->findArticlesFromSearch($search$ordernull) );
  509.             $articlesObjects $articleRepository->findArticlesFromSearch($search$order$limit);
  510.             $articles $articleEntityService->formatAll($articlesObjects);
  511.         } elseif (!empty($fin) && !empty($debut) && empty($search)) {
  512.             $count count($articleRepository->findArticlesFromDate($debut$fin$ordernull));
  513.             $articles $articleRepository->findArticlesFromDate($debut$fin$order$limit);
  514.             $articles $articleEntityService->formatAll($articles);
  515.         } else {
  516.             $count count($articleRepository->findArticlesFromAll($debut$fin$search$ordernull));
  517.             $articles $articleRepository->findArticlesFromAll($debut$fin$search$order$limit);
  518.             $articles $articleEntityService->formatAll($articles);
  519.         }
  520.         $html $this->renderView('search/_partials/articles.html.twig', [
  521.             'articles' => $articles,
  522.         ]);
  523.         return $this->json(['html' => $html'count' => $count'click' => $click], 200);
  524.     }
  525.     /**
  526.      * @Route("/articles/recherche/koisque", name="articles.recherche.koisque")
  527.      */
  528.     public function recherchekoisque(Request $requestStripeService $stripeService)
  529.     {
  530.         $search $request->get('search');
  531.         $fin $request->get('fin');
  532.         $debut $request->get('debut');
  533.         $order $request->get('order');
  534.         if ($request->get('limit')) {
  535.             $limit $request->get('limit');
  536.         } else {
  537.             $limit 10;
  538.         }
  539.         if (empty($fin) && empty($debut)) {
  540.             $products $stripeService->search($search$order$limit);
  541.         } elseif (!empty($fin) && !empty($debut) && empty($search)) {
  542.             $products $stripeService->filterByDate($debut$fin'ASC'$limit);
  543.         } else {
  544.             $products $stripeService->filterByAll($debut$fin$search$order$limit);
  545.         }
  546.         $html $this->renderView('search/_partials/articles.html.twig', [
  547.             'products' => $products,
  548.             'koisque' => 'koisque',
  549.         ]);
  550.         $count = \count($products);
  551.         return $this->json(['html' => $html$count], 200);
  552.     }
  553. }