<?php
namespace Customize\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Eccube\Controller\AbstractController;
use Eccube\Repository\ProductRepository;
class MakerSliderController extends AbstractController
{
/**
* @var ProductRepository
*/
protected $productRepository;
/**
* @param ProductRepository $productRepository
*/
public function __construct(
ProductRepository $productRepository
)
{
$this->productRepository = $productRepository;
}
/**
* @Route("/makerSlider/{id}", requirements={"id" = "\d+"}, name="makerSlider", methods={"GET"})
* @Template("makerSlider.twig")
*/
public function index(Request $request, ?int $id = null)
{
$products = $this->productRepository->findAll();
$num = count($products);
$order = [];
for($i=0; $i<$num;$i++) {
array_push($order, $products[$i]["id"]);
}
$productId = json_encode($order);
return [
"products" => $products,
"productId" => $productId,
'id' => $id,
];
}
}