Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions docs/components/cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ All you need to do now is to clear all tagged items:
.. code-block:: php

$cache->invalidateTags(['firstTag']);

Pools clearing
==============

Expand All @@ -54,6 +55,7 @@ Cache Pools include methods to delete a cache item, some of them, or all of them
.. code-block:: php

$isDeleted = $cache->deleteItem('user_'.$userId);

Use the ``Psr\\Cache\\CacheItemPoolInterface::deleteItems`` method to delete several cache items simultaneously - it returns true only if all the items have been deleted, even when any or some of them don't exist.

Configuration
Expand All @@ -68,6 +70,7 @@ These are the default settings:
'cache_adapter' => 'mautic.cache.adapter.filesystem',
'cache_prefix' => 'app',
'cache_lifetime' => 86400

They can be overridden in ``local.php`` like this:

.. code-block:: php
Expand All @@ -84,6 +87,7 @@ Delivered adapters
- ``mautic.cache.adapter.memcached``

.. code-block:: php

'memcached' => [
'servers' => ['memcached://localhost'],
'options' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Retrieving Mautic settings in Twig
=============================================
##################################

Mautic allows you to access configuration settings directly in Twig templates using the ``configGetParameter`` function. This feature is particularly useful for creating display conditions or showing existing data in your templates.

Basic usage
-----------
***********

To retrieve a setting, use the ``configGetParameter`` function with the parameter name as its argument:

Expand All @@ -13,7 +13,7 @@ To retrieve a setting, use the ``configGetParameter`` function with the paramete
{{ configGetParameter('parameter_name') }}

Display conditions
------------------
==================

Use ``configGetParameter`` in conditional statements to control the display of content based on configuration settings:

Expand All @@ -24,7 +24,7 @@ Use ``configGetParameter`` in conditional statements to control the display of c
{% endif %}

Displaying configuration values
-------------------------------
===============================

To directly display a configuration value in your template, use the following syntax:

Expand All @@ -45,12 +45,12 @@ For example, to display the API OAuth2 access token lifetime:
API OAuth2 Access Token Lifetime: {{ configGetParameter('api_oauth2_access_token_lifetime') }}

Finding available parameters
----------------------------
============================

The ``/config/local.php`` file contains available configuration parameters, once you save the global configuration form for the first time. This file contains the complete list of settings that are accessible using ``configGetParameter``.

Identifying parameter names
---------------------------
===========================

To find the correct parameter name for a specific setting:

Expand All @@ -67,7 +67,7 @@ For example, if you see:
The corresponding parameter name would be ``api_oauth2_access_token_lifetime``.

Additional information
----------------------
**********************

- Be cautious when displaying sensitive configuration data in templates.
- Always consider providing default values when using configuration parameters to handle cases where the setting aren't defined.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ There are several ways to support Mautic other than contributing with code.
:caption: Design and UX
:hidden:

design/retrieving_system_settings
design/retrieving_system_information

.. toctree::
:maxdepth: 2
Expand Down
24 changes: 12 additions & 12 deletions docs/plugins/from-4-to-5.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Update Plugins for Mautic 5
=======================================
###########################

Here is a list of steps that most of the Plugins may need to take to upgrade from Mautic 4 to Mautic 5. You should be able to get through each step, make a commit, move to the next one and once you are at finished you have upgraded your Plugin.

Continuous Integration
-------------------------
**********************

If you don't have CI configured, this is the time to do it. This is an optional step but it makes sense to do it at the beginning rather than later. Here's how to get it done: :doc:`/plugins/continuous-integration`.

In your PR add also support for PHP 8.1 and 8.2, and upgrade the Mautic version from 4.4 to 5.1. One more thing is that Mautic 5 have ``local.php`` in ``config/local.php`` instead of ``app/config/local.php`` so update that as well.

Autowiring
-------------
**********

Mautic 5 comes with autowiring of PHP services which means the developer experience is much improved, and the code size is reduced.

Expand All @@ -24,7 +24,7 @@ To quickly verify that the wiring of services is complete and configured correct
.. note:: Ideally, you should be able to delete the whole ``services`` section from your ``config.php`` file, but do that as a cherry on top once you are sure everything is working as the later steps in this process may yet cause you difficulties.

``config.php`` - controllers
---------------------------
****************************

``config.php`` should be much lighter now when all services are gone after autowiring is configured. There is one more thing to verify. The controllers are now defined with a different syntax. Here is an example:

Expand All @@ -36,7 +36,7 @@ To quickly verify that the wiring of services is complete and configured correct
Symfony 5 is much more explicit. That's a good thing even if it's longer. You don't have to guess what the syntax is. It's basically just standard FQCN (Fully Qualified Class Name) with the full method name behind the 2 colons. You don't even need to call the controller method `*Action` any more.

Rendering views
------------------
***************

As Symfony 5 removed the PHP templating engine, Mautic had to switch to Twig. Your Plugin must also update the any views from PHP to Twig. Here is a helpful resource on how to migrate the ``*.html.php`` files to ``*.html.twig`` files:

Expand All @@ -58,7 +58,7 @@ Running this command is faster than refreshing all the views in the browser. It
.. vale off

The Integration class
------------------------
*********************

.. vale on

Expand All @@ -72,7 +72,7 @@ If you went ahead and deleted all services from ``config.php``, you may experien
.. note:: Replace `[MY_INTEGRATION]` with your Plugin name.

Compiler passes
------------------
***************

If your Plugin uses a compiler pass, you may have to verify that it works correctly. In many cases you may have to change the service alias with FQCN like so:

Expand All @@ -82,7 +82,7 @@ If your Plugin uses a compiler pass, you may have to verify that it works correc
+ ->setDecoratedService(EmailType::class, 'mautic.form.type.email.inner')

Getting container in tests
-----------------------------
**************************

This one is a quick find and replace:

Expand All @@ -94,7 +94,7 @@ This one is a quick find and replace:
Notice you can also use FQCN instead of string service keys which is more convenient.

Automated refactoring
------------------------
**********************

Your Plugin should be working on Mautic 5 by now. Wouldn't it be great to shorten the code a little more? Mautic 5 uses PHP 8.0+ so can take advantage of the syntax. Rector can upgrade the code for you.

Expand All @@ -103,14 +103,14 @@ Run ``bin/rector process plugins/MyBundle`` and review the changes.
.. note:: Update MyBundle with your bundle name.

Automated code style
-----------------------
********************

Another great way how to improve your Plugin code base quality is to run the CS Fixer: ``bin/php-cs-fixer fix plugins/MyBundle``.

.. note:: Update MyBundle with your bundle name.

Static analysis
-------------------
***************

PHPSTAN is another amazing tool that detects bugs for you. It's better to run it on the whole codebase including core Mautic, so it's aware of all classes.

Expand All @@ -119,6 +119,6 @@ Run ``composer phpstan``
If your Plugin has more PHPSTAN errors than you can handle right now, consider using :xref:`PHPSTAN baseline`. It allows you to store your tech debt to a single file and it forces you to write better code from now on. And you can reduce the baseline by small chunks every month to get to 0.

Conclusion
----------
**********

This list of steps is compiled by Mautic Plugin developers for the Mautic Plugin developers. If you find that some common problem isn't addressed here, please add it.
Loading