app/Customize/Controller/MakerSliderController.php line 34

Open in your IDE?
  1. <?php
  2. namespace Customize\Controller;
  3. use Symfony\Component\HttpFoundation\Request;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  6. use Eccube\Controller\AbstractController;
  7. use Eccube\Repository\ProductRepository;
  8. class MakerSliderController extends AbstractController
  9. {
  10.     /**
  11.      * @var ProductRepository
  12.      */
  13.     protected $productRepository;
  14.     /**
  15.      * @param ProductRepository $productRepository
  16.      */
  17.     public function __construct(
  18.       ProductRepository $productRepository
  19.     )
  20.     {
  21.       $this->productRepository $productRepository;
  22.     }
  23.     /**
  24.      * @Route("/makerSlider/{id}", requirements={"id" = "\d+"}, name="makerSlider", methods={"GET"})
  25.      * @Template("makerSlider.twig")
  26.      */
  27.     public function index(Request $request,  ?int $id null)
  28.     {
  29.           $products $this->productRepository->findAll();
  30.           $num count($products);
  31.           $order = [];
  32.           for($i=0$i<$num;$i++) {
  33.             array_push($order$products[$i]["id"]);
  34.           }
  35.           $productId json_encode($order);
  36.           return [
  37.               "products" => $products,
  38.               "productId" => $productId,
  39.               'id' => $id,
  40.           ];
  41.     }
  42. }