-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathSamplePaymentEvent.php
67 lines (59 loc) · 2.05 KB
/
SamplePaymentEvent.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* https://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Plugin\SamplePayment42;
use Eccube\Event\TemplateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class SamplePaymentEvent implements EventSubscriberInterface
{
/**
* リッスンしたいサブスクライバのイベント名の配列を返します。
* 配列のキーはイベント名、値は以下のどれかをしてします。
* - 呼び出すメソッド名
* - 呼び出すメソッド名と優先度の配列
* - 呼び出すメソッド名と優先度の配列の配列
* 優先度を省略した場合は0
*
* 例:
* - array('eventName' => 'methodName')
* - array('eventName' => array('methodName', $priority))
* - array('eventName' => array(array('methodName1', $priority), array('methodName2')))
*
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{
return [
'Shopping/index.twig' => 'onShoppingIndexTwig',
'Shopping/confirm.twig' => 'onShoppingConfirmTwig',
'@admin/Order/edit.twig' => 'onAdminOrderEditTwig',
'Mypage/navi.twig' => 'onMypageNaviTwig',
];
}
public function onShoppingIndexTwig(TemplateEvent $event)
{
$event->addSnippet('@SamplePayment42/credit.twig');
}
public function onShoppingConfirmTwig(TemplateEvent $event)
{
$event->addSnippet('@SamplePayment42/credit_confirm.twig');
}
public function onAdminOrderEditTwig(TemplateEvent $event)
{
$event->addSnippet('@SamplePayment42/admin/order_edit.twig');
}
public function onMypageNaviTwig(TemplateEvent $event)
{
$source = $event->getSource();
$source .= file_get_contents(__DIR__.'/Resource/template/navi.twig');
$event->setSource($source);
}
}