Skip to content

Reference core services by FQCN instead of removed string service ids - #626

Open
promptless-for-oss wants to merge 1 commit into
mautic:7.2from
Promptless:promptless/pr-17124-service-reference-fqcn
Open

Reference core services by FQCN instead of removed string service ids#626
promptless-for-oss wants to merge 1 commit into
mautic:7.2from
Promptless:promptless/pr-17124-service-reference-fqcn

Conversation

@promptless-for-oss

Copy link
Copy Markdown
Contributor

Open in Promptless

mautic/mautic PR #17124 ("[phpstan] Prefer class service references, drop redundant aliases and setter calls", merged into 8.x) adds PHPStan rules that drop redundant string container service aliases across bundles. Two of the removed ids appear in the plugin developer docs as the way to reference a core service, so those code samples go stale on Mautic 8: the string ids no longer resolve, while the classes stay registered and autowire-injectable under their Fully Qualified Class Name (FQCN). This mirrors the already-accepted FQCN-swap pattern from PR #16875 (docs PR #612).

This updates each affected reference to use the FQCN instead of the removed string service id:

  • docs/plugin_extensions/emails.rst — the Email transport plugin config.php example passed 'mautic.helper.core_parameters' as a constructor argument; it now passes \Mautic\CoreBundle\Helper\CoreParametersHelper::class (fully qualified, since that config.php block has no use statements).
  • docs/plugins/config.rst — the helloworld.mars.validator plugin config.php example passed the same removed id as an argument; it now passes \Mautic\CoreBundle\Helper\CoreParametersHelper::class. The adjacent 'helloworld.helper.world' entry is a plugin-defined service and is left as a string.
  • docs/plugins/cache.rst — the cache code sample retrieved the provider via $this->get('mautic.cache.provider'); it now uses $this->get(\Mautic\CacheBundle\Cache\CacheProvider::class).

Trigger Events

mautic/mautic PR #17124 dropped the redundant 'mautic.helper.core_parameters'
and 'mautic.cache.provider' string service aliases on Mautic 8. The classes stay
registered and autowire-injectable, so plugin config.php examples and the cache
sample now reference them by fully-qualified class name.
'serviceAlias' => 'swiftmailer.mailer.transport.%s',
'arguments' => [
'mautic.helper.core_parameters',
\Mautic\CoreBundle\Helper\CoreParametersHelper::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 8.x PR #17124 (merge commit dc0a515) dropped the mautic.helper.core_parameters alias from CoreBundle/Config/services.php (previously aliased at old line ~94) and switched the sole internal consumer to service(Mautic\CoreBundle\Helper\CoreParametersHelper::class). CoreParametersHelper.php is not in MauticCoreExtension::DEFAULT_EXCLUDES nor CoreBundle's local excludes, so it remains auto-registered/autowirable under its FQCN via the bundle's services->load() call. Confirms the doc's FQCN reference is the correct current way to reference this service.

Source: https://github.com/mautic/mautic/blob/dc0a5159d316dd5f0189be9aa6f158a5702ca2a0/app/bundles/CoreBundle/Config/services.php#L140

Comment thread docs/plugins/config.rst
'class' => MauticPlugin\HelloWorldBundle\Form\Validator\Constraints\MarsValidator::class,
'arguments' => [
'mautic.helper.core_parameters',
\Mautic\CoreBundle\Helper\CoreParametersHelper::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.

Same evidence as emails.rst:574 — PR #17124 removed the mautic.helper.core_parameters string alias on 8.x; Mautic\CoreBundle\Helper\CoreParametersHelper remains registered/autowirable under its FQCN (see services.php load() call and DEFAULT_EXCLUDES), so \Mautic\CoreBundle\Helper\CoreParametersHelper::class is the correct current reference.

Source: https://github.com/mautic/mautic/blob/dc0a5159d316dd5f0189be9aa6f158a5702ca2a0/app/bundles/CoreBundle/Config/services.php#L140

Comment thread docs/plugins/cache.rst

/** @var CacheProvider $cache */
$cache = $this->get('mautic.cache.provider');
$cache = $this->get(\Mautic\CacheBundle\Cache\CacheProvider::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 8.x PR #17124 (merge commit dc0a515) dropped the mautic.cache.provider alias from CacheBundle/Config/services.php (previously at old line ~30, aliasing 'mautic.cache.provider' to Mautic\CacheBundle\Cache\CacheProvider::class). Mautic\CacheBundle\Cache\CacheProvider is still a registered service (see the surviving alias of CacheProviderInterface::class to CacheProvider::class on L36, and CacheProvider.php is not excluded from the bundle's services->load() autoregistration), confirming CacheProvider::class resolves as a valid service id. Note: the doc sample omits a use Mautic\CacheBundle\Cache\CacheProvider; import or leading backslash, unlike the other two FQCN replacements in this PR — flagged separately as a prose correction.

Source: https://github.com/mautic/mautic/blob/dc0a5159d316dd5f0189be9aa6f158a5702ca2a0/app/bundles/CacheBundle/Config/services.php#L36

@TomasVotruba

Copy link
Copy Markdown

All good 👍

@adiati98 adiati98 added this to the 8.0 milestone Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants