MishkaCmsCore.Runtime.Resources.Changes.PluginBeforeHook (Mishka CMS Core v0.0.1)

Copy Markdown View Source

A reusable before_action change that lets a plugin transform or reject an action before it runs (the WordPress wp_insert_post_data / pre_comment_approved, Joomla onContentBeforeSave seam).

Add it to the actions you want to gate:

create :create_public do
  change MishkaCmsCore.Runtime.Resources.Changes.PluginBeforeHook
  ...
end

It hands the plugin the changeset for "<app>:<resource>:before_<action>"; the plugin returns the (possibly modified) changeset, or Ash.Changeset.add_error(changeset, ...) to reject. With no plugin registered, the changeset passes through untouched.

A before_action makes the action non-atomic. That is harmless on create actions, but on update/destroy it flips an unauthorized request from 403 to 404 (the non-atomic path loads the record first). So prefer it on creates + admin-only actions; rely on the after-notifier elsewhere.

See MishkaCmsCore.Runtime.Resources.Notifiers.PluginHook (after events) and MishkaInstaller.Event.Hook.