Home > Enterprise >  Too few arguments to function Mautic\PluginBundle\Integration\AbstractIntegration::__construct(),
Too few arguments to function Mautic\PluginBundle\Integration\AbstractIntegration::__construct(),

Time:02-06

I'm trying to develop a plugin for Mautic 3.

I need to use AbstractIntegration's method appendToForm(&$builder, $data, $formArea), but when I do the next:

<?php
namespace MauticPlugin\MauticCampaignSmtpBundle\Integration;

use Mautic\PluginBundle\Integration\AbstractIntegration;
    
class CampaignSmtpIntegration extends AbstractIntegration {
    //some code without __construct class
}

I'm receiving an error

Too few arguments to function Mautic\PluginBundle\Integration\AbstractIntegration::__construct(), 0 passed ... and exactly 16 expected

I saw the code of AbstractIntegration class and its __construct() has 16 arguments, but when I looked on another working plugin, I saw the working extended AbstractIntegration class.

<?php
namespace MauticPlugin\MauticGmailBundle\Integration;

use Mautic\PluginBundle\Integration\AbstractIntegration;

class GmailIntegration extends AbstractIntegration
{
}

What am I doing wrong?

CodePudding user response:

The GmailIntegration class does not define a constructor, so it inherits the 16-argument constructor from AbstractIntegration just like your class does.

The plugin contains a config.php file that defines the service and lists all 16 expected arguments:

    'services'    => [
        'integrations' => [
            'mautic.integration.gmail' => [
                'class'     => \MauticPlugin\MauticGmailBundle\Integration\GmailIntegration::class,
                'arguments' => [
                    'event_dispatcher',
                    'mautic.helper.cache_storage',
                    'doctrine.orm.entity_manager',
                    'session',
                    'request_stack',
                    'router',
                    'translator',
                    'logger',
                    'mautic.helper.encryption',
                    'mautic.lead.model.lead',
                    'mautic.lead.model.company',
                    'mautic.helper.paths',
                    'mautic.core.model.notification',
                    'mautic.lead.model.field',
                    'mautic.plugin.model.integration_entity',
                    'mautic.lead.model.dnc',
                ],
            ],
        ],
    ],

Your custom plugin needs to include a config file that also lists the 16 required constructor arguments.

  •  Tags:  
  • Related