MishkaCmsCore.Runtime.Resources.Preparations.PluginQueryHook (Mishka CMS Core v0.0.1)

Copy Markdown View Source

A reusable read Preparation that lets a plugin adjust the query before a read runs — the WordPress pre_get_posts / posts_where, Joomla onContentSearch seam.

Add it to the read actions you want to make pluggable:

read :published do
  prepare MishkaCmsCore.Runtime.Resources.Preparations.PluginQueryHook
  ...
end

It hands the plugin the Ash.Query for "<app>:<resource>:query_<action>"; the plugin returns a modified Ash.Query (e.g. Ash.Query.filter/2, Ash.Query.sort/2). With no plugin registered, the query passes through untouched. Reads are not atomic, so this changes no authorization behaviour.

Reads run per request — keep plugins cheap and add only indexed filters/sorts; never break the resource's base/tenant filters.

See MishkaInstaller.Event.Hook.

Summary

Functions

init(opts)

Callback implementation for Ash.Resource.Preparation.init/1.

supports(opts)

Callback implementation for Ash.Resource.Preparation.supports/1.

temporal_safe?(opts)

Callback implementation for Ash.Resource.Preparation.temporal_safe?/1.