Skip to content

Reference CorePermissions by FQCN instead of the removed mautic.security service id - #625

Draft
promptless-for-oss wants to merge 1 commit into
mautic:7.2from
Promptless:promptless/pr-17121-mautic-security-fqcn
Draft

Reference CorePermissions by FQCN instead of the removed mautic.security service id#625
promptless-for-oss wants to merge 1 commit into
mautic:7.2from
Promptless:promptless/pr-17121-mautic-security-fqcn

Conversation

@promptless-for-oss

Copy link
Copy Markdown
Contributor

Open in Promptless

Mautic 8 (mautic/mautic PR #17121) replaces the PermissionsPass compiler pass with an AutowireIterator on CorePermissions and removes the mautic.security container service id along with its alias. The FQCN Mautic\CoreBundle\Security\Permissions\CorePermissions is now the only container identifier for the security service.

The plugin developer docs still reference the removed mautic.security id when showing how to obtain the security service, so those examples break on Mautic 8. This updates the four affected places to use the CorePermissions FQCN instead:

  • docs/plugins/permissions.rst — the "Using permissions" $this->get() example and the prose that names the service.
  • docs/plugin_services/security.rst — the same $this->get() example and prose; the prose no longer claims a mautic.security alias exists.
  • docs/plugins/config.rst — the methodCalls example that passed mautic.security as a service reference.
  • docs/plugin_extensions/api.rst — the controller arguments example that passed mautic.security.

The mautic.permissions service tag and the services.permissions registration group — how plugin developers register their own permission classes — are unchanged by the PR and are left untouched. This is a behavior-preserving reference swap consistent with the established pattern for other removed string service aliases.

Trigger Events

…ity service id

Mautic 8 (mautic/mautic PR #17121) replaces the PermissionsPass compiler
pass with an AutowireIterator on CorePermissions and removes the
mautic.security container service id and its alias. The FQCN
Mautic\CoreBundle\Security\Permissions\CorePermissions is now the only
container identifier for the security service, so update the plugin
developer examples that still reference the removed mautic.security id.
<?php

$security = $this->get('mautic.security');
$security = $this->get(\Mautic\CoreBundle\Security\Permissions\CorePermissions::class);

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.

mautic/mautic PR #17121 removes the 'mautic.security' service id and its alias to CorePermissions::class in app/bundles/CoreBundle/Config/services.php, registering CorePermissions under its FQCN id instead ($services->set(Mautic\CoreBundle\Security\Permissions\CorePermissions::class)). Confirms $this->get(CorePermissions::class) is the correct replacement for $this->get('mautic.security').

Source: https://github.com/mautic/mautic/pull/17121/files


/** @var \Mautic\CoreBundle\Security\Permissions\CorePermissions */
$security = $this->get('mautic.security');
$security = $this->get(\Mautic\CoreBundle\Security\Permissions\CorePermissions::class);

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.

mautic/mautic PR #17121 removes the 'mautic.security' service id/alias and registers CorePermissions under its FQCN id in app/bundles/CoreBundle/Config/services.php. Confirms $this->get(CorePermissions::class) replaces $this->get('mautic.security').

Source: https://github.com/mautic/mautic/pull/17121/files


/** @var \Mautic\CoreBundle\Security\Permissions\CorePermissions */
$security = $this->get('mautic.security');
$security = $this->get(\Mautic\CoreBundle\Security\Permissions\CorePermissions::class);

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.

Mautic's core services.php sets $services->defaults()->autowire()->autoconfigure()->public(), so services are public by default unless explicitly marked private. CorePermissions (registered by FQCN id with no ->public(false) override) remains a publicly gettable container service after PR #17121, so $this->get(CorePermissions::class) works the same way $this->get('mautic.security') did before.

Source: https://github.com/mautic/mautic/blob/505f0a7b912fa78ccaa01dd4d434ae2ceb1d6b43/app/bundles/CoreBundle/Config/services.php#L20

Comment thread docs/plugins/config.rst
- no
- array[]
- Define methods to call after the service is instantiated. Use an array of arrays with keys as the method name and values the arguments to pass into the given method. For example, ``['methodCalls' => ['setSecurity' => ['mautic.security'],],],``.
- Define methods to call after the service is instantiated. Use an array of arrays with keys as the method name and values the arguments to pass into the given method. For example, ``['methodCalls' => ['setSecurity' => [\Mautic\CoreBundle\Security\Permissions\CorePermissions::class],],],``.

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.

mautic/mautic PR #17121 removes the 'mautic.security' service id/alias, registering CorePermissions under its FQCN id. The methodCalls example argument must reference the new FQCN id.

Source: https://github.com/mautic/mautic/pull/17121/files

'class' => \MauticPlugin\HelloWorldBundle\Controller\ApiController::class,
'arguments' => [
'mautic.security',
\Mautic\CoreBundle\Security\Permissions\CorePermissions::class,

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.

mautic/mautic PR #17121 removes the 'mautic.security' service id/alias, registering CorePermissions under its FQCN id. Per docs/plugins/config.rst's own documentation of the 'arguments' key ("Any other string is assumed to be the name of a defined service"), the controller's constructor argument must reference the new FQCN service id.

Source: https://github.com/mautic/mautic/pull/17121/files

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