You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plugins/config.rst
+18-16Lines changed: 18 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -704,19 +704,21 @@ Configure parameters that are consumable through Mautic's ``CoreParameterHelper`
704
704
705
705
Custom config parameters
706
706
************************
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.
708
708
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.
710
710
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.
712
712
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.
715
717
- A specific view for rendering the form.
716
718
717
719
.. note::
718
720
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.
720
722
721
723
722
724
Config event subscriber
@@ -793,15 +795,15 @@ Subscribed events
793
795
The event subscriber listens to the following events:
794
796
795
797
- ``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.
797
799
798
800
- ``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``.
800
802
801
-
Handling configuration generation
803
+
Generate plugin configuration
802
804
---------------------------------
803
805
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:
805
807
806
808
.. list-table::
807
809
:header-rows: 1
@@ -813,23 +815,23 @@ To register the plugin’s configuration details during the ``ConfigEvents::CONF
813
815
* - ``formTheme``
814
816
- The view that formats the configuration form elements, e.g., ``HelloWorldBundle:FormTheme\Config``.
815
817
* - ``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.
817
819
818
-
Manipulating configuration before save
820
+
Modify configuration before saving
819
821
--------------------------------------
820
822
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.
822
824
823
-
Registering the subscriber
825
+
Register the event subscriber
824
826
--------------------------
825
827
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.
827
829
828
830
829
831
Config form
830
832
=============
831
833
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.
833
835
834
836
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>`_
0 commit comments