File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
lib/alchemy/configurations Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ def index
5757 items = items . page ( params [ :page ] || 1 ) . per ( items_per_page )
5858 @pages = items
5959 elsif @current_language . root_page
60- @root_page = Alchemy :: PageTreePreloader . new (
60+ @root_page = Alchemy . config . page_tree_loader_class . new (
6161 page : @current_language . root_page ,
6262 user : current_alchemy_user
6363 ) . call
@@ -173,7 +173,10 @@ def fold
173173 respond_to do |format |
174174 format . turbo_stream do
175175 if was_folded
176- @page = PageTreePreloader . new ( page : @page , user : current_alchemy_user ) . call
176+ @page = Alchemy . config . page_tree_loader_class . new (
177+ page : @page ,
178+ user : current_alchemy_user
179+ ) . call
177180 else
178181 head :ok
179182 end
Original file line number Diff line number Diff line change @@ -29,7 +29,10 @@ def nested
2929 @page = Page . find_by ( id : params [ :page_id ] ) || Language . current_root_page
3030
3131 # Preload the full tree from this page
32- preloaded_page = PageTreePreloader . new ( page : @page , user : current_alchemy_user ) . call
32+ preloaded_page = Alchemy . config . page_tree_loader_class . new (
33+ page : @page ,
34+ user : current_alchemy_user
35+ ) . call
3336
3437 render json : PageTreeSerializer . new (
3538 preloaded_page ,
Original file line number Diff line number Diff line change @@ -378,6 +378,14 @@ class Main < Alchemy::Configuration
378378 # Default is 1 hour.
379379 #
380380 option :update_check_cache_duration , :integer , default : 1
381+
382+ # === Page tree loader class
383+ #
384+ # The class used to preload page trees with all associations and children.
385+ # Must respond to .new(page:, user:).call
386+ #
387+ # @default Alchemy::PageTreePreloader
388+ option :page_tree_loader_class , :class , default : "Alchemy::PageTreePreloader"
381389 end
382390 end
383391end
You can’t perform that action at this time.
0 commit comments