Last active
December 8, 2020 01:58
-
-
Save kurozumi/ab31d919373da13c9862d3b7100dc5d2 to your computer and use it in GitHub Desktop.
CustomerTypeController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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