<?php
/*
* This file is part of the Productset
*
* Copyright (C) 2018 Diezon.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\Productset42;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Eccube\Event\TemplateEvent;
use Plugin\Productset42\Controller\Front\Mypage\MypageController;
use Plugin\Productset42\Controller\Front\FrontProductController;
use Plugin\Productset42\Controller\Front\CartController;
use Plugin\Productset42\Controller\Front\ShoppingController;
use Plugin\Productset42\Controller\Admin\Product\ProductController;
use Plugin\Productset42\Controller\Admin\Product\ProductClassController;
use Plugin\Productset42\Controller\Admin\Order\OrderController;
use Plugin\Productset42\Controller\Admin\Order\EditController;
class Event implements EventSubscriberInterface
{
/**
* @var MypageController
*/
private $mypageController;
/**
* @var FrontProductController
*/
private $frontProductController;
/**
* @var CartController
*/
private $cartController;
/**
* @var ShoppingController
*/
private $shoppingController;
/**
* @var ProductController
*/
private $productController;
/**
* @var ProductClassController
*/
private $productClassController;
/**
* @var OrderController
*/
private $orderController;
/**
* @var EditController
*/
private $editController;
/**
* @param FrontProductController $frontProductController
* @param CartController $cartController
* @param ProductController $productController
* @param ProductClassController $productClassController
* @param OrderController $orderController
* @param EditController $editController
*/
public function __construct(MypageController $mypageController,
FrontProductController $frontProductController,
CartController $cartController,
ShoppingController $shoppingController,
ProductController $productController,
ProductClassController $productClassController,
OrderController $orderController,
EditController $editController)
{
$this->mypageController = $mypageController;
$this->frontProductController = $frontProductController;
$this->cartController = $cartController;
$this->shoppingController = $shoppingController;
$this->productController = $productController;
$this->productClassController = $productClassController;
$this->orderController = $orderController;
$this->editController = $editController;
}
/**
* 定数からメソッド名を作成する
*
* @param CONST
* @return methodName
*/
private static function getMethodName($const)
{
$words = explode('.', $const);
$methodName = null;
foreach ($words as $word) {
$methodName .= ucfirst($word);
}
$methodName = 'on' . $methodName;
return $methodName;
}
/**
* 使用するイベントを設定する
*
* @return array
*/
public static function getSubscribedEvents()
{
return [
'Mypage/history.twig' => 'onRenderFrontMypageHistory',
'Cart/index.twig' => 'onRenderFrontCartIndex',
'Shopping/index.twig' => 'onRenderFrontShopping',
'Shopping/confirm.twig' => 'onRenderFrontShopping',
'Product/list.twig' => 'onRenderFrontProductList',
'Product/detail.twig' => 'onRenderFrontProductDetail',
'@admin/Product/index.twig' => 'onRenderAdminProductIndex',
'@admin/Product/product.twig' => 'onRenderAdminProductProduct',
EccubeEvents::ADMIN_PRODUCT_CSV_EXPORT => self::getMethodName(EccubeEvents::ADMIN_PRODUCT_CSV_EXPORT),
'@admin/Product/product_class.twig' => 'onRenderAdminProductProductClass',
EccubeEvents::ADMIN_ORDER_CSV_EXPORT_ORDER => self::getMethodName(EccubeEvents::ADMIN_ORDER_CSV_EXPORT_ORDER),
EccubeEvents::ADMIN_ORDER_CSV_EXPORT_SHIPPING => self::getMethodName(EccubeEvents::ADMIN_ORDER_CSV_EXPORT_SHIPPING),
EccubeEvents::ADMIN_ORDER_EDIT_INDEX_COMPLETE => self::getMethodName(EccubeEvents::ADMIN_ORDER_EDIT_INDEX_COMPLETE),
'@admin/Order/edit.twig' => 'onRenderAdminOrderEdit',
];
}
// --------------------------------------------------------------------------------
// Mypage\MypageController
/**
* history
*/
/**
* Mypage/history.twig
*
* @param TemplateEvent $event
*/
public function onRenderFrontMypageHistory(TemplateEvent $event)
{
$this->mypageController->onRenderFrontMypageHistory($event);
}
// --------------------------------------------------------------------------------
// CartController
/**
* index
*/
/**
* Cart/index.twig
*
* @param TemplateEvent $event
*/
public function onRenderFrontCartIndex(TemplateEvent $event)
{
$this->cartController->onRenderFrontCartIndex($event);
}
// --------------------------------------------------------------------------------
// ShoppingController
/**
* index
*/
/**
* Shopping/index.twig
*
* @param TemplateEvent $event
*/
public function onRenderFrontShopping(TemplateEvent $event)
{
$this->shoppingController->onRenderFrontShopping($event);
}
// --------------------------------------------------------------------------------
// ProductController
/**
* Product/detail.twig
*
* @param TemplateEvent $event
*/
public function onRenderFrontProductList(TemplateEvent $event)
{
$this->frontProductController->onRenderFrontProductList($event);
}
/**
* Product/detail.twig
*
* @param TemplateEvent $event
*/
public function onRenderFrontProductDetail(TemplateEvent $event)
{
$this->frontProductController->onRenderFrontProductDetail($event);
}
// --------------------------------------------------------------------------------
// Admin\Product\ProductController
/**
* index
*/
/**
* Admin/Product/index.twig
*
* @param TemplateEvent $event
*/
public function onRenderAdminProductIndex(TemplateEvent $event)
{
$this->productController->onRenderAdminProductIndex($event);
}
/**
* edit
*/
/**
* Admin/Product/product.twig
*
* @param TemplateEvent $event
*/
public function onRenderAdminProductProduct(TemplateEvent $event)
{
$this->productController->onRenderAdminProductProduct($event);
}
/**
* export
*/
/**
* admin.product.csv.export
*
* @param EventArgs $event
*/
public function onAdminProductCsvExport(EventArgs $event)
{
$this->productController->onAdminProductCsvExport($event);
}
// --------------------------------------------------------------------------------
// Admin\Product\ProductClassController
/**
* index
*/
/**
* Admin/Product/product_class.twig
*
* @param TemplateEvent $event
*/
public function onRenderAdminProductProductClass(TemplateEvent $event)
{
$this->productClassController->onRenderAdminProductProductClass($event);
}
// --------------------------------------------------------------------------------
// Admin\Order\OrderController
/**
* exportOrder
*/
/**
* admin.order.csv.export.order
*
* @param EventArgs $event
*/
public function onAdminOrderCsvExportOrder(EventArgs $event)
{
$this->orderController->onAdminOrderCsvExportOrder($event);
}
/**
* exportShipping
*/
/**
* admin.order.csv.export.shipping
*
* @param EventArgs $event
*/
public function onAdminOrderCsvExportShipping(EventArgs $event)
{
$this->orderController->onAdminOrderCsvExportShipping($event);
}
// --------------------------------------------------------------------------------
// Admin\Order\EditController
/**
* index
*/
/**
* admin.order.edit.index.complete
*
* @param EventArgs $event
*/
public function onAdminOrderEditIndexComplete(EventArgs $event)
{
$this->editController->onAdminOrderEditIndexComplete($event);
}
// --------------------------------------------------------------------------------
// Admin\Order\EditController
/**
* Admin/Order/edit.twig
*
* @param TemplateEvent $event
*/
public function onRenderAdminOrderEdit(TemplateEvent $event)
{
$this->editController->onRenderAdminOrderEdit($event);
}
}