I have just started recently with the working with Mautic and with the development of new plugins.
In my current stage I got a small plugin written (also mainly following the development guidelines from https://developer.mautic.org) which fetches some data from a given source.
Now my idea is that this fetched data is stored in the contacts table.
There a pretty straightforward (and what has been recommended in the development guide (link)) approach is to create a new instance of “Mautic\LeadBundle\Entity\Lead” in one of my controllers, set the required fields, and persist in the database.
I have tested this and it works.
To tune this I would lke to provide a configurable mapper concept as like in the Social Plugin (let’s take the Instagram one for now), which is set in the Plugin configuration.
I presume that this is the “Mautic” way of doing that. The development guide describes this as “Integration” but doesn’t show how to add this mapper and instead refers to the documentation of the extended class: “AbstractIntegration”. There I found this method: “getAvailableLeadFields”, which seems to do the job. Checking the code from the Social Plugin I have seen that this method is overwritten. So I created an Integration class in my plugin including this overwritten method. However when I put this into my Integration class the “mapping” register chart still does not appear.
I checked the code of the Mautic bundle for the Integration and there I found this snippet:
/* … */ $hasFields = (!empty($formSettings[‘dynamic_contact_fields’]) || isset($form[‘featureSettings’]) && count($form[‘featureSettings’][‘leadFields’]))
<?php if ($hasFields): ?> <li class="<?php echo $fieldTabClass; ?> <?php if (isset($activeTab) && $activeTab == 'leadFieldsContainer'): echo 'active'; endif; ?> " id="fields-tab"> <a href="#fields-container" role="tab" data-toggle="tab"> <?php echo $view['translator']->trans('mautic.plugin.integration.tab.fieldmapping'); ?> <?php if ($hasLeadFieldErrors): ?> <i class="fa fa-fw fa-warning text-danger"></i> <?php endif; ?> </a> </li> <?php endif; ?>
So it seems that I have to define an additional form for that?
And there is the point where I got lost since the documentation ended here and the social plugin doesn’t give any hint to me, as well. So I would like to raise these questions:
- Is there a straight forward example of how to implement such a mapper in the plugin configuration?
- After this mapper is set in the configuration, how is this information processed in the plugin, so that it fetches its data from somewhere and files it into the Leads table according to this mapping?
(I haven’t found anything for that. In case I have missed it just point me to the code)?