Update custom permission class docs for Mautic 8 DI service registration - #622
Update custom permission class docs for Mautic 8 DI service registration#622promptless-for-oss wants to merge 6 commits into
Conversation
Reflects mautic/mautic PR #17079: custom permission classes now use a no-argument constructor (the array $params argument is deprecated), receive resolved core parameters via an autowired setter after construction, and are registered as DI services in Config/services.php where Mautic autoconfigures the mautic.permissions tag.
|
I noticed that some CI checks failed for this PR. I'm investigating whether the failures are caused by this suggestion. If they're unrelated or pre-existing, I'll leave this suggestion unchanged and create a separate suggestion if a standalone docs fix is needed. |
definePermissions() was removed in mautic/mautic PR #17079; permissions are now defined in the class constructor. Correct the 'Examining permission files' list and add a Mautic 8 version note.
|
I noticed that some CI checks failed for this PR. I'm investigating whether the failures are caused by this suggestion. If they're unrelated or pre-existing, I'll leave this suggestion unchanged and create a separate suggestion if a standalone docs fix is needed. |
adiati98
left a comment
There was a problem hiding this comment.
@promptless-for-oss please address the suggestions.
|
Thanks @adiati98 — on it. I'll apply your suggested rewrite on the permissions orientation page and the active-voice fix on |
|
Update: applying your suggested rewrite on the permissions orientation page verbatim, and converting the flagged passive phrase to active voice on |
- Apply @adiati98's verbatim suggestion to the Mautic 8 permission note in displaying_elements_based_on_user_permissions.rst - Convert passive 'runs after the object is constructed' to active 'runs after construction completes' in security.rst and permissions.rst
|
Addressed your review on PR #622. Your suggested wording for the Mautic 8 permission-class note is now applied exactly as written, and I converted the flagged passive-voice sentence in the |
|
@promptless-for-oss please rebase to 8.0 branch. |
|
In reply to this discussion Done — PR #622 now targets the |
Open in Promptless
Mautic 8 changes how plugins define custom permission classes (subclasses of
AbstractPermissions). This updates the developer docs to match.For Mautic 8 and later, a custom permission class uses a no-argument constructor: the
array $paramsconstructor argument is deprecated, so classes no longer declare it or callparent::__construct($params). Mautic now injects the resolved core parameters through an autowired setter that runs after construction, so$this->paramsis available in every method except the constructor. Permission definitions live in the constructor (the removeddefinePermissions()method is no longer used). The docs also add guidance to register the permission class as a service in the bundle'sConfig/services.php, which Mautic autoconfigures with themautic.permissionstag; an unregistered class still works through a deprecated fallback.The custom-permission example and constructor guidance appear on two pages (
docs/plugins/permissions.rstanddocs/plugin_services/security.rst); both are updated to the Mautic 8 constructor pattern to keep them consistent. The orientation pagedocs/design/displaying_elements_based_on_user_permissions.rst, which describes what a permission file typically contains, is also corrected: its list no longer references the removeddefinePermissions()method, and a Mautic 8 version note points readers to the constructor.Trigger Events
Review feedback addressed (@adiati98)
docs/design/displaying_elements_based_on_user_permissions.rst(note) — applied verbatim: your suggested wording now reads "This pattern applies to Mautic 8 and later. Permission classes define their permissions in the__construct()method. Earlier Mautic versions used adefinePermissions()method instead."docs/plugin_services/security.rst__construct()section — applied: converted the flagged passive clause to active voice — "runs after the object is constructed" → "runs after construction completes".docs/plugins/permissions.rst__construct()section was converted to the same active phrasing ("runs after construction completes") so both pages stay consistent.Vale passes on the changed content.