docs: プラグインフックポイント一覧ドキュメントを追加#1249
Conversation
EC-CUBE2のプラグイン開発で利用可能なすべてのフックポイントの完全なリファレンスを作成しました。 - docs/plugin-hook-points.md を新規追加 - スーパーフックポイント(システム全体) - ローカルフックポイント(ページクラス別) - API関連フックポイント - 特殊なフックポイント - 実装例とコードサンプル - 統計情報 - docs/README.md にプラグイン開発セクションとリンクを追加 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1249 +/- ##
=======================================
Coverage 54.39% 54.39%
=======================================
Files 83 83
Lines 10658 10658
=======================================
Hits 5797 5797
Misses 4861 4861
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@coderabbitai レビューお願いします。特に使用例のコードについて検証してください |
🧩 Analysis chain🏁 Script executed: Length of output: 41 🏁 Script executed: Length of output: 24593 🏁 Script executed: Length of output: 863 🏁 Script executed: Length of output: 0 🏁 Script executed: Length of output: 0 🏁 Script executed: Length of output: 100 🏁 Script executed: Length of output: 11643 🏁 Script executed: Length of output: 233 🏁 Script executed: Length of output: 3219 🏁 Script executed: Length of output: 9830 🏁 Script executed: Length of output: 493 🏁 Script executed: Length of output: 3922 🏁 Script executed: Length of output: 404 🏁 Script executed: Length of output: 2413 🏁 Script executed: Length of output: 6824 🏁 Script executed: Length of output: 12746 🏁 Script executed: Length of output: 295 🏁 Script executed: Length of output: 6807 🏁 Script executed: Length of output: 873 🏁 Script executed: Length of output: 0 🏁 Script executed: Length of output: 951 🏁 Script executed: Length of output: 784 🏁 Script executed: Length of output: 783 🏁 Script executed: Length of output: 634 🏁 Script executed: Length of output: 5217 🏁 Script executed: Length of output: 238 🏁 Script executed: Length of output: 615 🏁 Script executed: Length of output: 1625 🏁 Script executed: Length of output: 1080 🏁 Script executed: Length of output: 7037 🏁 Script executed: Length of output: 160 🏁 Script executed: Length of output: 1603 🏁 Script executed: Length of output: 86
重大な問題1. テンプレートフックポイントのメソッドシグネチャが誤っています高度な使用例の public function transformOutput($output, $objSmarty)
{
// テンプレート出力の変換
return $output;
}実際の実装は:
正しいシグネチャ: public function outputfilterTransform(&$source, $objPage, $filename)
{
// テンプレート出力の変換
// $source を直接変更する(return不要)
}これは実際のテストフィクスチャ( 2. API関連フックポイントのセクションに誤解を招く記述がありますドキュメントの「API操作クラス」セクションにリストされている以下のクラスは、フックポイントではありません:
これらは 実際のAPIフックポイントは:
これらは他のページクラスと同様に 修正提案1. 高度な使用例を修正してください:<?php
class AdvancedPlugin extends SC_Plugin_Base
{
public function register($objPluginHelper, $priority)
{
// 複数のフックポイント登録
$hookPoints = [
'LC_Page_Admin_Order_Edit_action_before' => 'beforeOrderEdit',
'LC_Page_Admin_Order_Edit_action_after' => 'afterOrderEdit',
'LC_Page_Shopping_Confirm_action_confirm' => 'onOrderConfirm',
'outputfilterTransform' => 'transformOutput'
];
foreach ($hookPoints as $hookPoint => $method) {
$objPluginHelper->addAction($hookPoint, [$this, $method], $priority);
}
}
public function beforeOrderEdit($objPage)
{
// 受注編集前の処理
}
public function afterOrderEdit($objPage)
{
// 受注編集後の処理
}
public function onOrderConfirm($objPage)
{
// 注文確認時の処理
}
public function transformOutput(&$source, $objPage, $filename)
{
// テンプレート出力の変換
// $sourceを直接変更します(return不要)
if ($filename === 'shopping/confirm.tpl') {
$source .= '<!-- カスタム追加コンテンツ -->';
}
}
}2. API関連フックポイントのセクションを書き換えてください:現在の「API操作クラス」セクションを削除し、以下に置き換えることを推奨: ## API関連フックポイント
### APIページクラス
APIリクエストを処理するページクラスには、他のページクラスと同様にフックポイントが利用可能です。
| クラス名 | 利用可能なフックポイント |
|---------|---------------------|
| `LC_Page_Api` | `LC_Page_Api_action_before`<br>`LC_Page_Api_action_after` |
| `LC_Page_Api_Json` | `LC_Page_Api_Json_action_before`<br>`LC_Page_Api_Json_action_after` |
| `LC_Page_Api_Php` | `LC_Page_Api_Php_action_before`<br>`LC_Page_Api_Php_action_after` |
| `LC_Page_Api_Xml` | `LC_Page_Api_Xml_action_before`<br>`LC_Page_Api_Xml_action_after` |
注意: `API_CartAdd`、`API_ItemSearch` などの操作クラスは、フックポイントを提供しません。これらは `SC_Api_Operation` によって直接呼び出されます。その他の所見✅ 以下は正確です:
統計情報の修正「API関連クラス: 13個」という記述は、実際のAPIページクラスは4個のみであるため、修正が必要です。 上記の修正を行えば、このドキュメントはEC-CUBE2のプラグイン開発者にとって非常に価値のあるリファレンスになります。 ✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughプラグイン開発向けのドキュメントを追加・拡張しました。 Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@docs/plugin-hook-points.md`:
- Around line 443-446: Update the statistics entry that currently reads
"API関連クラス: 13個" to the correct count "API関連クラス: 4個" and, if present, list or
validate the four API page classes LC_Page_Api, LC_Page_Api_Json,
LC_Page_Api_Php, and LC_Page_Api_Xml so the doc reflects the actual classes.
- Around line 318-333: Remove or replace the misleading "API操作クラス" table: delete
the table rows listing AddrFromZip, BrowseNodeLookup, CartAdd, CartClear,
CartCreate, CartGet, CartModify, Default, GetVersion, ItemLookup, ItemSearch
(and any similar API operation classes) and instead add a short note that these
API operation classes are not hook-providing and are "フックポイント対象外"; explicitly
state that API-related hooks are provided only on the LC_Page_Api* side to avoid
confusion.
- Around line 399-437: The example registers an output filter but defines
transformOutput($output, $objSmarty) and returns a value; replace that with the
correct outputfilter signature and behavior: in AdvancedPlugin change the hooked
method name to outputfilterTransform and implement it as
outputfilterTransform(&$source, $objPage, $filename) — edit $source by reference
(no return) — and update the $hookPoints entry ('outputfilterTransform' =>
'outputfilterTransform') so the registered hook matches the method name.
- outputfilterTransformのメソッドシグネチャを実装に合わせて修正 (&$source, $objPage, $filename) - API操作クラス(API_CartAdd等)はフックポイントではないため削除 - サンプルコードからSC_Plugin_Base継承を除去(EC-CUBE#551) - 統計情報のAPIクラス数を修正(13→4) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
EC-CUBE2のプラグイン開発で利用可能なすべてのフックポイントの完全なリファレンスドキュメントを作成しました。
追加内容
docs/plugin-hook-points.md- フックポイント一覧の完全なドキュメントdocs/README.md- プラグイン開発セクションとリンクを追加ドキュメントの特徴
含まれる内容
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
ドキュメント
✏️ Tip: You can customize this high-level summary in your review settings.