Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public function add(PagesServiceInterface $service)
$page = $service->create($this->request->getData());
$message = __d('baser_core', '固定ページ「{0}」を追加しました。', $page->content->title);
$this->BcMessage->setSuccess($message, true, false);
// EVENT Pages.afterAdd
$this->dispatchLayerEvent('afterAdd', [
'data' => $page,
]);
Comment on lines +103 to +106
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同様の afterAdd 発火コードが Pages / BlogPosts の両方に追加されており、今後イベント名やペイロード構造を変更したくなった場合に差分が生まれやすいです。API 管理系の共通基底(または trait / ヘルパーメソッド)に「追加完了イベント発火」を集約するか、少なくともイベント名(afterAdd)とペイロードキー(data)を定数化して、タイポや実装差異が入りにくい形に寄せるのを検討してください。

Copilot uses AI. Check for mistakes.
} catch (PersistenceFailedException $e) {
$errors = $e->getEntity()->getErrors();
$message = __d('baser_core', "入力エラーです。内容を修正してください。");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public function add(BlogPostsServiceInterface $service)
$blogPost = $service->create($this->request->getData());
$message = __d('baser_core', '記事「{0}」を追加しました。', $blogPost->title);
$this->BcMessage->setSuccess($message, true, false);
// EVENT BlogPosts.afterAdd
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメント上は「BlogPosts.afterAdd」と記載されていますが、実際の呼び出しは dispatchLayerEvent('afterAdd', ...) になっています。dispatchLayerEvent() が内部で BlogPosts. を付与する仕様でない場合、コメントと実際に発火するイベント名がズレて誤解を招くので、(1) 実際に発火するイベント名にコメントを合わせる、または (2) プロジェクトの慣例に合わせて発火側のイベント名指定を修正する、のどちらかに統一すると良いです。あわせて、リスナー側が期待するペイロード(例: data キー)であることがわかる一言があると保守しやすいです。

Suggested change
// EVENT BlogPosts.afterAdd
// EVENT afterAdd (payload: ['data' => $blogPost])

Copilot uses AI. Check for mistakes.
$this->dispatchLayerEvent('afterAdd', [
'data' => $blogPost,
]);
} catch (PersistenceFailedException $e) {
$this->setResponse($this->response->withStatus(400));
$errors = $e->getEntity()->getErrors();
Expand Down
Loading