Add service attribute to page definition - a proposal#3840
Draft
kulturbande wants to merge 6 commits intoAlchemyCMS:mainfrom
Draft
Add service attribute to page definition - a proposal#3840kulturbande wants to merge 6 commits intoAlchemyCMS:mainfrom
kulturbande wants to merge 6 commits intoAlchemyCMS:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3840 +/- ##
==========================================
- Coverage 98.06% 98.06% -0.01%
==========================================
Files 322 324 +2
Lines 8530 8561 +31
==========================================
+ Hits 8365 8395 +30
- Misses 165 166 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add an abstract page service and a corresponding page_layout. The service is used to make the initialization of page services easier and less error prone.
the page service can be used to initialize and call a service. This type is validating that the service exists and that it inherit from BasePageService.
The service can be any class that is callable and that is inheriting the service structure of Alchemy::BasePageService.
It is only syntactic sugar, but it read later nicer in the controllers.
Create a @service variable that is containing the initialized services. After that the service will be called. The service can fire an Alchemy::PageNotFound error that is interesting the current user is not allowed to see the page. The service also gets the parameters that maybe contain also wildcard_url parameter.
The same behavior as before, except that this controller does not rescue the Alchemy::PageNotFound error. Instead the service will be initialized with the preview_mode flag, which is interesting to populate other data in the preview window.
fe7bf03 to
2fa0dd8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this pull request for?
This PR introduces a page service concept. It is is possible to declare a service class in the page_layout.yml. The service runs during page loading (both frontend and admin preview) to prepare custom data or guard access.
This change goes hand in hand with PR #3776. In combination it would be possible to process the wildcard_url parameter in the service and load the part that was requested.
Screenshots
Page Layout:

Service:

View:

Checklist