Ticket #2181 (new 改善提案) — at Version 5
開発合宿:プラグインのインストーラ
Reported by: | adachi | Owned by: | somebody |
---|---|---|---|
Priority: | 中 | Milestone: | EC-CUBE2.13.0 |
Component: | フロント | Version: | 2.12.3 |
Keywords: | Cc: | ||
修正済み: | yes |
Description (last modified by h_yoshimoto) (diff)
プラグインインストーラ
以下は、現状プラグイン任せなので、エラーがおきやすい
・インストール ・アンインストール ・有効 ・無効
インストール用ユーティリティを用意し、プラグイン作成者に使ってもらう
※テーブル作成、ファイルコピー、ブロック追加など
フロー
* フロー LC_Page_Admin_OwnersStore::installPlugin - トランザクション開始 (SC_QUery::begin()) - プラグインアーカイブの一時ディレクトリを初期化 - 必須拡張モジュールのチェック - アーカイブを一時ディレクトリに解凍 - plugin_info.phpを読み込み - plugin_info.phpの内容チェック - プラグインコードから、既にプラグインがインストールされているかチェック - dtb_pluginへレコードを登録 - 一時ディレクトリから, プラグイン保存ディレクトリへコピー - プラグインメインクラスをロード - プラグインHTMLディレクトリを作成 - プラグインインストーラを生成 - プラグインのinstallメソッドを実行 PLUGIN::install($arrPlugin, $objInstaller); - ★インストーラがインストール処理を実行 (SC_Plugin_Installer::execPlugin()) - トランザクション終了(SC_Query::commit()) - 一時ディレクトリ削除 * インストール処理のフロー SC_Plugin_Installer::execPlugin() - SQLの検証 -- SQLエラーがある場合はreturn; - SQLの実行 - INSERT実行 - UPDATE実行 - ディレクトリコピー - ファイルコピー
利用イメージ
* インストーラで利用できるメソッド - sql($sql, $params) SQLを実行 - sqlInsert($table, $entity); INSERT - sqlUpdate($table, $entity, $where, $params) UPDATE - sqlAterTableAddColumn($table_name, $col_name, $col_type) カラム追加 - sqlAterTableDropColumn($table_name, $col_name) カラム削除 - copyFile($src, $dist) html/plugin_code以下にコピー - copyDirectory($src, $dist) html/plugin_code以下にコピー * プラグイン側の利用イメージ install($arrPlugin, $objPluginInstaller) { // カラム追加 $objPluginInstaller->sqlAterTableAddColumn("dtb_products" ,"plg_plugin_code_hoge", "text"); // テーブル追加 $objPluginInstaller->sql( "create table plg_plugin_code_hogehugatable ( hoge_id int not null primary key hoge_name text)"); // data/downloads/plugin/plugin_code/media/hoge.cssをhtml/plugin/plugin_code/media/huga.cssへコピー $objPluginInstaller->copyFile("media/hoge.css", "media/huga.css"); // data/downloads/plugin/plugin_code/js/以下をhtml/plugin/plugin_code/js/へコピー $objPluginInstaller->copyDirectory("js", "js"); // INSERT処理 $sqlval = array(); $sqlval['dummy'] = "test"; $objPluginInstaller->sqlInsert('plg_plugin_code_hogehugatable ', $sqlval); } uninstall($arrPlugin, $objPluginInstaller) { // カラム削除 $objPluginInstaller->sqlAterTableDropColumn("dtb_products", "plg_plugin_code"); // テーブル削除 $objPluginInstaller->sql("drop table plg_plugin_code_hoge"); // ファイル削除 html以下はアンインストール時にまるっと削除される }
その他
インストール時のログは、ログ管理から閲覧可能(プラグインログ)
Change History
Changed 11 years ago by h_yoshimoto
- attachment plugin_info2.tar.gz added
comment:1 Changed 11 years ago by adachi
使い方:
install($arrPlugin, $objPluginInstaller) { // カラム追加 $objPluginInstaller->sql("alter table dtb_products add column plg_plugin_code_hoge text"); // テーブル追加 $objPluginInstaller->sql( "create table plg_plugin_code_hogehugatable ( hoge_id int not null primary key hoge_name text)"); // data/downloads/plugin/plugin_code/media/hoge.cssをhtml/plugin/plugin_code/media/huga.cssへコピー $objPluginInstaller->copyFile("media/hoge.css", "media/huga.css"); // data/downloads/plugin/plugin_code/js/以下をhtml/plugin/plugin_code/js/へコピー $objPluginInstaller->copyDirectory("js", "js"); }
Changed 11 years ago by h_yoshimoto
- attachment CategoryContents_error.tar.gz added
エラー出るプラグインをアップデート
Note: See
TracTickets for help on using
tickets.
エラー出るプラグイン