Skip to content

Instantly share code, notes, and snippets.

@kurozumi
Last active December 8, 2020 01:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kurozumi/ab31d919373da13c9862d3b7100dc5d2 to your computer and use it in GitHub Desktop.
CustomerTypeController
<?php
/**
* This file is part of CustomerType
*
* Copyright(c) Akira Kurozumi <info@a-zumi.net>
*
* https://a-zumi.net
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\CustomerType\Controller;
use Eccube\Controller\AbstractController;
use Eccube\Entity\Customer;
use Plugin\CustomerType\Service\Customer\CustomerTypeContext;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\Routing\Annotation\Route;
class CustomerTypeController extends AbstractController
{
/**
* @var CustomerTypeContext
*/
private $customerTypeContext;
public function __construct(CustomerTypeContext $customerTypeContext)
{
$this->customerTypeContext = $customerTypeContext;
}
/**
* @return Response
*
* @Route("/customer/type", name="customer_type")
*/
public function index()
{
if (!$this->getUser() instanceof Customer) {
throw new AccessDeniedHttpException();
}
$customerType = $this->customerTypeContext->getCustomerType($this->getUser());
$message = trans("あなたは%name%です。", ["%name%" => $customerType->getName()]);
return new Response($message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment