![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/app/bundles/PluginBundle/EventListener/ |
<?php namespace Mautic\PluginBundle\EventListener; use Mautic\LeadBundle\Entity\Lead; use Mautic\PluginBundle\Helper\IntegrationHelper; use Mautic\PluginBundle\Integration\AbstractIntegration; /** * Static methods must be used due to the Point triggers not being converted to Events yet * Once that happens, this can be converted to a standard method classes. * * Trait PushToIntegrationTrait */ trait PushToIntegrationTrait { /** * @var IntegrationHelper */ protected static $integrationHelper; /** * Used by methodCalls to event subscribers. */ public function setIntegrationHelper(IntegrationHelper $integrationHelper): void { static::setStaticIntegrationHelper($integrationHelper); } /** * Used by callback methods such as point triggers. */ public static function setStaticIntegrationHelper(IntegrationHelper $integrationHelper): void { static::$integrationHelper = $integrationHelper; } protected function pushToIntegration(array $config, Lead $lead, array &$errors = []): bool { return static::pushIt($config, $lead, $errors); } /** * Used because the the Point trigger actions have not be converted to Events yet and thus must leverage a callback. */ protected static function pushIt($config, $lead, &$errors): bool { $integration = (!empty($config['integration'])) ? $config['integration'] : null; $integrationCampaign = (!empty($config['config']['campaigns'])) ? $config['config']['campaigns'] : null; $integrationMemberStatus = (!empty($config['campaign_member_status']['campaign_member_status'])) ? $config['campaign_member_status']['campaign_member_status'] : null; $services = static::$integrationHelper->getIntegrationObjects($integration); $success = true; foreach ($services as $s) { /** @var AbstractIntegration $s */ $settings = $s->getIntegrationSettings(); if (!$settings->isPublished()) { continue; } $personIds = null; if (method_exists($s, 'pushLead')) { if (!$personIds = $s->resetLastIntegrationError()->pushLead($lead, $config)) { $success = false; if ($error = $s->getLastIntegrationError()) { $errors[] = $error; } } } if ($success && $integrationCampaign && method_exists($s, 'pushLeadToCampaign')) { if (!$s->resetLastIntegrationError()->pushLeadToCampaign($lead, $integrationCampaign, $integrationMemberStatus)) { $success = false; if ($error = $s->getLastIntegrationError()) { $errors[] = $error; } } } } return $success; } }