Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions docs/plugin_services/parameters.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
Config parameters
#################

.. vale off
Use ``Mautic\CoreBundle\Helper\CoreParametersHelper`` to read Mautic's configuration parameters, including any your Plugin declares. Inject the helper into your service:

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 from the legacy _plugin_services_parameters.md include, which documented reading the helloworld_api_enabled config parameter via mautic.helper.core_parameters (Mautic\CoreBundle\Helper\CoreParametersHelper). Modernized to inject CoreParametersHelper and call get()/has()/all() per Mautic 7 service conventions, matching issue #366's guidance to update content while porting.

Source: https://raw.githubusercontent.com/mautic/developer-documentation/main/source/includes/_plugin_services_parameters.md

.. note::
.. code-block:: php

The content for this page requires a major update. The legacy page contains outdated and potentially inaccurate information. You can still access it in the :xref:`legacy repository`.
<?php

If you're interested in helping develop the new content for this page and others, consider joining the documentation efforts.
use Mautic\CoreBundle\Helper\CoreParametersHelper;

Please read the :xref:`dev docs contributing guidelines` and :xref:`Contributing to Mautic’s documentation` to get started.
final class ExampleService
{
public function __construct(private CoreParametersHelper $coreParametersHelper)
{
}

.. vale on
public function isApiEnabled(): bool
{
return (bool) $this->coreParametersHelper->get('helloworld_api_enabled', false);
}
}

Call ``get(string $name, $default = null)`` to read a single parameter with a fallback value. ``CoreParametersHelper`` also provides ``has()`` to confirm whether a parameter exists and ``all()`` to return every parameter.
Loading