Missing Documentation: Model Service - $_hook_id
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 35/100
- issue の種類
- ドキュメント
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- php
調査の方向性
Start with the “Building your own Models” guide named in the issue, then check the linked Model and Member source files to confirm how $_hook_id is used. Document the property and the hook naming behavior described in the issue; done means the guide explains which models expose extension hooks and how their event names are formed.
索引モデルが issue の本文から書いたものです。
説明
Suggested Change
The Model Service documentation is missing a description of the $_hook_id property. The example I have found that uses this property is within the Member Model.
Reasoning
I was developing an add-on that contains a Contact model which belongsTo the ee:Member model.
Being curious in the process in which member models are saved/updated/inserted/deleted, I went searching for the extension hook call before_member_save($member, $values).
Based on the documentation, I was lead to believe that all extension hooks are invoked via some code that looks like:
if (ee()->extensions->active_hook('some_hook_method') === TRUE)
{
$str = ee()->extensions->call('some_hook_method', $hook_args...);
}
Unable to locate the existence of such code, with the hook method before_member_save, I did some deeper digging.
I learned that Models, which extend the ExpressionEngine\Service\Model class invoke the forwardEventToHooks($event) method. Walking through the code of this method, I discovered that:
- Models which have a
$_hook_idproperty defined are exposed to extension hook calls (Event name, either 'insert', 'update', 'save', or 'delete') based on the following convention:
$forwarded = array(
'before' . $uc_first_event => 'before_' . $hook_basename . '_' . $event,
'after' . $uc_first_event => 'after_' . $hook_basename . '_' . $event
);
- Internal events on the Model are also emitted without having to call them externally: For example:
$model = ee('Model')->get('Member')->first();
$model->validate(); // internally, $this->emit('beforeValidate') and $this->emit('afterValidate') are called
$model->save(); // internally, $this->emit('beforeSave') and $this->emit('afterSave') are called
// .... etc
Before I was attaching my own events for these actions and having to emit (invoke) them manually.
Additional context
I would recommend adding this documentation here: Building your own Models
- 主要言語
- CSS
- スター
- 22
- フォーク
- 79
- 平均マージ
- 2日 1時間
- マージ済み PR(30日)
- 6
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ExpressionEngine/ExpressionEngine-User-Guide のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 55/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 55/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 46/100
ExpressionEngine/ExpressionEngine-User-Guide の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
obsidianmd/obsidian-developer-docs#281 ·
メンテナーはふだん 4 日以内に返信
-
Area: PDF support
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
orbeon/orbeon-forms#8053 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
JWhite212/SignalLadder#213 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
aws-samples/sample-per-model-bedrock#782 ·
メンテナーはふだん 1 日以内に返信
-
docs(sync): document `sync.local_source` and how to recover entries written before v1.42.0対応中かも @jdx が今日担当しました。 オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信