Skip to content

Commit 1f70453

Browse files
committed
docs: updated documentation for Configuration component.
1 parent 8f00a09 commit 1f70453

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

docs/plugins/config.rst

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -704,19 +704,21 @@ Configure parameters that are consumable through Mautic's ``CoreParameterHelper`
704704

705705
Custom config parameters
706706
************************
707-
Mautic plugins can define custom configuration parameters for use within their code. These parameters are typically stored in ``app/config/local.php``, and their default values should be defined in the plugin’s own config file to ensure stability and avoid errors.
707+
You can define custom configuration parameters in your plugin to support configurable features, such as enabling or disabling functionality.
708708

709-
To prevent Symfony from throwing errors during cache compilation, or when accessing parameters directly from the container without checking for existence, always define custom parameters in the `plugin’s config file <https://devdocs.mautic.org/en/latest/plugins/config.html#parameters-config-items>`_. This guarantees the parameter exists and has a fallback value.
709+
Mautic plugins allow you to define these parameters for use within your plugin’s code. Store these parameters in ``app/config/local.php``, and define their default values in the plugin’s own config file to ensure stability and avoid errors.
710710

711-
To add these configuration options in the Configuration page, you’ll need:
711+
To avoid errors during cache compilation or when accessing parameters directly from the container without checking for their existence, always define custom parameters in the `plugin’s config file <https://devdocs.mautic.org/en/latest/plugins/config.html#parameters-config-items>`_. This guarantees that the parameter exists and has a fallback value.
712712

713-
- An `event subscriber <https://devdocs.mautic.org/en/latest/plugins/event_listeners.html>`_ to register the configuration,
714-
- A `form type <https://devdocs.mautic.org/en/latest/components/forms.html>`_ that defines the fields, and
713+
To add these configuration options in the configuration page, you’ll need:
714+
715+
- An `event subscriber <https://devdocs.mautic.org/en/latest/plugins/event_listeners.html>`_ to register the configuration.
716+
- A `form type <https://devdocs.mautic.org/en/latest/components/forms.html>`_ that defines the fields.
715717
- A specific view for rendering the form.
716718

717719
.. note::
718720

719-
To translate the plugin’s tab label in the Configuration form, include a translation key like ``mautic.config.tab.helloworld_config`` in the plugin’s ``messages.ini`` file. Replace ``helloworld_config`` with the formAlias used when registering the form in the event subscriber.
721+
To translate the plugin’s tab label in the configuration form, include a translation key like ``mautic.config.tab.helloworld_config`` in the plugin’s ``messages.ini`` file. Replace ``helloworld_config`` with the ``formAlias`` used when registering the form in the event subscriber.
720722

721723

722724
Config event subscriber
@@ -793,15 +795,15 @@ Subscribed events
793795
The event subscriber listens to the following events:
794796

795797
- ``ConfigEvents::CONFIG_ON_GENERATE``:
796-
This event is dispatched when the configuration form is built, allowing the plugin to inject its own tab and configuration options.
798+
This event is dispatched when the configuration form is built. This allows the plugin to inject its own tab and configuration options.
797799

798800
- ``ConfigEvents::CONFIG_PRE_SAVE``:
799-
This event is triggered before the form values are rendered and saved to the ``local.php`` file. It gives the plugin an opportunity to clean up or manipulate the data before it is written.
801+
This event is triggered before the form values are rendered and saved to the ``local.php`` file. This allows the plugin to clean up or modify the data before writing it to ``local.php``.
800802

801-
Handling configuration generation
803+
Generate plugin configuration
802804
---------------------------------
803805

804-
To register the plugin’s configuration details during the ``ConfigEvents::CONFIG_ON_GENERATE`` event, the plugin must call the ``addForm()`` method on the ``ConfigBuilderEvent`` object. The method expects an array with the following elements:
806+
To register plugin’s configuration details during the ``ConfigEvents::CONFIG_ON_GENERATE event``, call the ``addForm()`` method on the ``ConfigBuilderEvent`` object. The method expects an array with the following elements:
805807

806808
.. list-table::
807809
:header-rows: 1
@@ -813,23 +815,23 @@ To register the plugin’s configuration details during the ``ConfigEvents::CONF
813815
* - ``formTheme``
814816
- The view that formats the configuration form elements, e.g., ``HelloWorldBundle:FormTheme\Config``.
815817
* - ``parameters``
816-
- An array of custom config elements. You can use ``$event->getParametersFromConfig('HelloWorldBundle')`` to retrieve them from the plugin’s config file.
818+
- An array of custom configuration elements. ``Use $event->getParametersFromConfig('HelloWorldBundle')`` to retrieve them from the plugin’s configuration file.
817819

818-
Manipulating configuration before save
820+
Modify configuration before saving
819821
--------------------------------------
820822

821-
To manipulate or clean up the form data before it is saved, use the ``ConfigEvents::CONFIG_PRE_SAVE`` event. This event is triggered just before the values are saved into the ``local.php`` file. It allows the plugin to adjust the values before they are written.
823+
To modify the form data before saving, use the ``ConfigEvents::CONFIG_PRE_SAVE event``. This event is triggered just before values are saved to the ``local.php`` file, allowing the plugin to adjust them.
822824

823-
Registering the subscriber
825+
Register the event subscriber
824826
--------------------------
825827

826-
Remember that the subscriber must be registered through the plugin’s configuration in the ``services[events]`` `section <https://devdocs.mautic.org/en/latest/plugins/config.html#service-config-items>`_. This ensures that the plugin listens for the events and reacts accordingly.
828+
Register the subscriber through the plugin’s configuration in the ``services[events]`` `section <https://devdocs.mautic.org/en/latest/plugins/config.html#service-config-items>`_. This ensures that the plugin listens for the events and reacts accordingly.
827829

828830

829831
Config form
830832
=============
831833

832-
The form type is used to generate the form fields in the main configuration form. Refer to the `Forms documentation <https://devdocs.mautic.org/en/latest/components/forms.html>`_ for more information on using form types.
834+
The form type is used to generate the form fields in the main configuration form. See the `Forms documentation <https://devdocs.mautic.org/en/latest/components/forms.html>`_ for more information about using form types.
833835

834836
Remember that the form type must be registered through the plugin’s config in the ``services[forms]`` `section <https://devdocs.mautic.org/en/latest/plugins/config.html#service-config-items>`_
835837
.

0 commit comments

Comments
 (0)