EC-CUBE4でゲスト購入を無効化する方法です。
<?php namespace Customize\EventSubscriber; use Eccube\Controller\NonMemberShoppingController; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpKernel\Event\FilterControllerEvent; use Symfony\Component\Routing\RouterInterface; /** * ゲスト購入ページにアクセスしたら会員登録ページへリダイレクト * * Class NonMemberSubscriber * @package Customize\EventSubscriber */ class NonMemberSubscriber implements EventSubscriberInterface { /** * @var RouterInterface */ private $router; public function __construct( RouterInterface $router ) { $this->router = $router; } public function onKernelController(FilterControllerEvent $event) { $controllers = $event->getController(); if(!is_array($controllers)) { return; } foreach($controllers as $controller) { if($controller instanceof NonMemberShoppingController) { $event->setController(function(){ return new RedirectResponse($this->router->generate("entry")); }); break; } } } public static function getSubscribedEvents() { return [ 'kernel.controller' => 'onKernelController', ]; } }