1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved. |
---|
6 | * |
---|
7 | * http://www.lockon.co.jp/ |
---|
8 | * |
---|
9 | * This program is free software; you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License |
---|
11 | * as published by the Free Software Foundation; either version 2 |
---|
12 | * of the License, or (at your option) any later version. |
---|
13 | * |
---|
14 | * This program is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this program; if not, write to the Free Software |
---|
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
22 | * |
---|
23 | * |
---|
24 | */ |
---|
25 | |
---|
26 | /** |
---|
27 | * プラグインの基底クラス |
---|
28 | * |
---|
29 | * @package Plugin |
---|
30 | * @author LOCKON CO.,LTD. |
---|
31 | * @version $Id: $ |
---|
32 | */ |
---|
33 | abstract class SC_Plugin_Base { |
---|
34 | |
---|
35 | protected $arrSelfInfo; |
---|
36 | |
---|
37 | /** |
---|
38 | * コンストラクタ |
---|
39 | * |
---|
40 | * @param array $arrSelfInfo 自身のプラグイン情報 |
---|
41 | * @return void |
---|
42 | */ |
---|
43 | function __construct(array $arrSelfInfo) { |
---|
44 | $this->arrSelfInfo = $arrSelfInfo; |
---|
45 | } |
---|
46 | /** |
---|
47 | * インストール |
---|
48 | * installはプラグインのインストール時に実行されます. |
---|
49 | * 引数にはdtb_pluginのプラグイン情報が渡されます. |
---|
50 | * |
---|
51 | * @param array $arrPlugin plugin_infoを元にDBに登録されたプラグイン情報(dtb_plugin) |
---|
52 | * @return void |
---|
53 | */ |
---|
54 | abstract function install($arrPlugin); |
---|
55 | |
---|
56 | /** |
---|
57 | * アンインストール |
---|
58 | * uninstallはアンインストール時に実行されます. |
---|
59 | * 引数にはdtb_pluginのプラグイン情報が渡されます. |
---|
60 | * |
---|
61 | * @param array $arrPlugin プラグイン情報の連想配列(dtb_plugin) |
---|
62 | * @return void |
---|
63 | */ |
---|
64 | abstract function uninstall($arrPlugin); |
---|
65 | |
---|
66 | /** |
---|
67 | * 稼働 |
---|
68 | * enableはプラグインを有効にした際に実行されます. |
---|
69 | * 引数にはdtb_pluginのプラグイン情報が渡されます. |
---|
70 | * |
---|
71 | * @param array $arrPlugin プラグイン情報の連想配列(dtb_plugin) |
---|
72 | * @return void |
---|
73 | */ |
---|
74 | abstract function enable($arrPlugin); |
---|
75 | |
---|
76 | /** |
---|
77 | * 停止 |
---|
78 | * disableはプラグインを無効にした際に実行されます. |
---|
79 | * 引数にはdtb_pluginのプラグイン情報が渡されます. |
---|
80 | * |
---|
81 | * @param array $arrPlugin プラグイン情報の連想配列(dtb_plugin) |
---|
82 | * @return void |
---|
83 | */ |
---|
84 | abstract function disable($arrPlugin); |
---|
85 | |
---|
86 | /** |
---|
87 | * プラグインヘルパーへ, コールバックメソッドを登録します. |
---|
88 | * |
---|
89 | * @param object $objPluginHelper |
---|
90 | * @param integer $priority |
---|
91 | */ |
---|
92 | function register(SC_Helper_Plugin $objHelperPlugin, $priority) { |
---|
93 | if (isset($this->arrSelfInfo['plugin_hook_point'])) { |
---|
94 | $arrHookPoints = $this->arrSelfInfo['plugin_hook_point']; |
---|
95 | foreach ($arrHookPoints as $hook_point) { |
---|
96 | if (isset($hook_point['callback'])) { |
---|
97 | $hook_point_name = $hook_point['hook_point']; |
---|
98 | $callback_name = $hook_point['callback']; |
---|
99 | $objHelperPlugin->addAction($hook_point_name, array($this, $callback_name), $priority); |
---|
100 | } |
---|
101 | } |
---|
102 | } |
---|
103 | } |
---|
104 | } |
---|