Skip to content

docs: Port "User" service page to 7.2#578

Open
promptless-for-oss wants to merge 1 commit into
mautic:7.2from
Promptless:promptless/docs-issue-391-user-7.2
Open

docs: Port "User" service page to 7.2#578
promptless-for-oss wants to merge 1 commit into
mautic:7.2from
Promptless:promptless/docs-issue-391-user-7.2

Conversation

@promptless-for-oss

Copy link
Copy Markdown
Contributor

Open this suggestion in Promptless to view citations and reasoning process

Ports the legacy User helper guide into docs/plugin_services/user.rst, converting the legacy Markdown to RST and modernizing it to constructor injection of UserHelper. Targets the 7.2 base branch per the team's plan to set content in 7.2 first, then cherry-pick to 7.1/7.0/6.0/5.x. Resolves docs issue #391 (parent #390).

Trigger Events


Tip: Sort by Shortest Review in the Dashboard to find quick wins ⚡

Ports the legacy User helper guide (mautic/developer-documentation
_plugin_services_users.md) into docs/plugin_services/user.rst,
converting Markdown to RST and modernizing to constructor injection
of UserHelper. Targets 7.2 per the team's plan to set content in 7.2
first, then cherry-pick to 7.1/7.0/6.0/5.x.

Resolves docs issue mautic#391 (parent mautic#390).
.. vale on No newline at end of file
.. vale on

Use the ``Mautic\CoreBundle\Helper\UserHelper`` service to retrieve the currently logged-in User. Inject it into your service or subscriber through the constructor:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ported this page's UserHelper usage from the legacy Markdown file _plugin_services_users.md, which documented retrieving the current User via the mautic.helper.user service and calling getUser(). Modernized the legacy $this->get('mautic.helper.user') fetch to constructor injection of UserHelper and corrected the getter casing (getFirstName()/getLastName()).

Source: https://github.com/mautic/developer-documentation/blob/main/source/includes/_plugin_services_users.md

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Line 45)

Verified the documented behavior against UserHelper::getUser() on the 7.x branch: its signature is getUser($nullIfGuest = false): ?User, so passing true returns null when the request has no authenticated User (otherwise it returns a guest User). Also confirmed getFirstName(), getLastName(), getEmail(), getRole() on UserBundle\Entity\User and Role::isAdmin() exist as used in the example.

Source: https://github.com/mautic/mautic/blob/7.x/app/bundles/CoreBundle/Helper/UserHelper.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant