source: branches/camp/camp-2_13-plugin/data/class/plugin/SC_Plugin_Base.php @ 22634

Revision 22634, 3.7 KB checked in by adachi, 11 years ago (diff)

#2181 SC_Plugin_Base修正

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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 */
33abstract class SC_Plugin_Base
34{
35
36    protected $arrSelfInfo;
37
38    /**
39     * コンストラクタ
40     *
41     * @param array $arrSelfInfo 自身のプラグイン情報
42     * @return void
43     */
44    function __construct(array $arrSelfInfo)
45    {
46        $this->arrSelfInfo = $arrSelfInfo;
47    }
48    /**
49     * インストール
50     * installはプラグインのインストール時に実行されます.
51     * 引数にはdtb_pluginのプラグイン情報が渡されます.
52     *
53     * @param array $arrPlugin plugin_infoを元にDBに登録されたプラグイン情報(dtb_plugin)
54     * @return void
55     */
56    abstract function install($arrPlugin, $objPluginInstaller = null);
57
58    /**
59     * アンインストール
60     * uninstallはアンインストール時に実行されます.
61     * 引数にはdtb_pluginのプラグイン情報が渡されます.
62     *
63     * @param array $arrPlugin プラグイン情報の連想配列(dtb_plugin)
64     * @return void
65     */
66    abstract function uninstall($arrPlugin, $objPluginInstaller = null);
67
68    /**
69     * 稼働
70     * enableはプラグインを有効にした際に実行されます.
71     * 引数にはdtb_pluginのプラグイン情報が渡されます.
72     *
73     * @param array $arrPlugin プラグイン情報の連想配列(dtb_plugin)
74     * @return void
75     */
76    abstract function enable($arrPlugin, $objPluginInstaller = null);
77
78    /**
79     * 停止
80     * disableはプラグインを無効にした際に実行されます.
81     * 引数にはdtb_pluginのプラグイン情報が渡されます.
82     *
83     * @param array $arrPlugin プラグイン情報の連想配列(dtb_plugin)
84     * @return void
85     */
86    abstract function disable($arrPlugin, $objPluginInstaller = null);
87
88    /**
89     * プラグインヘルパーへ, コールバックメソッドを登録します.
90     *
91     * @param object $objPluginHelper
92     * @param integer $priority
93     */
94    function register(SC_Helper_Plugin $objHelperPlugin, $priority)
95    {
96        if (isset($this->arrSelfInfo['plugin_hook_point'])) {
97            $arrHookPoints = $this->arrSelfInfo['plugin_hook_point'];
98            foreach ($arrHookPoints as $hook_point) {
99                if (isset($hook_point['callback'])) {
100                    $hook_point_name = $hook_point['hook_point'];
101                    $callback_name   = $hook_point['callback'];
102                    $objHelperPlugin->addAction($hook_point_name, array($this, $callback_name), $priority);
103                }
104            }
105        }
106    }
107
108    /**
109     * このプラグインのプラグイン情報を返す。
110     *
111     * @return array $arrSelfInfo 自身のプラグイン情報
112     */
113    function getPluginInfo()
114    {
115        return $this->arrSelfInfo;
116    }
117
118}
Note: See TracBrowser for help on using the repository browser.