File size: 624 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

namespace Mautic\PointBundle\Helper;

use Mautic\LeadBundle\Entity\Lead;

class EventHelper
{
    /**
     * @param Lead  $lead
     * @param array $action
     *
     * @return int
     */
    public static function engagePointAction($lead, $action)
    {
        static $initiated = [];

        $pointsChange = 0;

        // only initiate once per lead per type
        if (empty($initiated[$lead->getId()][$action['type']])) {
            if (!empty($action['properties']['delta'])) {
                $pointsChange = $action['properties']['delta'];
            }
        }

        return $pointsChange;
    }
}