<?php
/*
* This file is part of the CouponPro42 Plugin
*
* Copyright (C) 2022 Diezon.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\CouponPro42\Controller\Block;
use Eccube\Controller\AbstractController;
use Plugin\CouponPro42\Service\CouponHelper;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class CouponBlockController extends AbstractController
{
/** @var CouponHelper */
protected $couponHelper;
public function __construct(CouponHelper $couponHelper) {
$this->couponHelper = $couponHelper;
}
/**
* @Route("/block/coupon", name="block_coupon", methods={"GET"})
* @Template("Block/coupon.twig")
*/
public function index(Request $request)
{
$couponData = $this->couponHelper->getMyCouponsForCouponBlock($this->getUser());
return [
'Coupons' => $couponData['Coupons'],
'usedStatusCoupons' => $couponData['isUsed'],
];
}
}