Mautic Community Forums

Problem with start event LeadEvents::LEAD_POINTS_CHANGE on mautic 2.5.1

I have problem with start event LeadEvents::LEAD_POINTS_CHANGE on mautic 2.5.1 in my plugin.

After research I find place in code where code should change in file app/bundles/LeadBundle/Entity/Lead.php in method isChanged now is

Code:
protected function isChanged($prop, $val, $oldValue = null) { $getter = 'get' . ucfirst($prop); $current = ($oldValue) ? $oldValue : $this->$getter(); if ( $prop == 'owner' ) { if ( $current && !$val ) { $this->changes['owner'] = [$current->getId(), $val ]; } elseif ( !$current && $val ) { $this->changes['owner'] = [$current, $val->getId() ]; } elseif ( $current && $val && $current->getId() != $val->getId() ) { $this->changes['owner'] = [$current->getId(), $val->getId() ]; } } elseif ( $prop == 'ipAddresses' ) { $this->changes['ipAddresses'] = ['', $val->getIpAddress() ]; } elseif ( $prop == 'tags' ) { if ( $val instanceof Tag ) { $this->changes['tags']['added'][] = $val->getTag(); } else { $this->changes['tags']['removed'][] = $val; } } elseif ( $prop == 'utmtags' ) { if ( $val instanceof UtmTag ) { if ( $val->getUtmContent() ) { $this->changes['utmtags'] = ['utm_content', $val->getUtmContent() ]; } if ( $val->getUtmMedium() ) { $this->changes['utmtags'] = ['utm_medium', $val->getUtmMedium() ]; } if ( $val->getUtmCampaign() ) { $this->changes['utmtags'] = ['utm_campaign', $val->getUtmCampaign() ]; } if ( $val->getUtmTerm() ) { $this->changes['utmtags'] = ['utm_term', $val->getUtmTerm() ]; } if ( $val->getUtmSource() ) { $this->changes['utmtags'] = ['utm_source', $val->getUtmSource() ]; } } } elseif ( $prop == 'frequencyRules' ) { if ( $val instanceof FrequencyRule ) { if ( $val->getFrequencyTime() ) { $this->changes['frequencyRules'] = ['frequency_time', $val->getFrequencyTime() ]; } if ( $val->getFrequencyNumber() ) { $this->changes['frequencyRules'] = ['frequency_number', $val->getFrequencyNumber() ]; } } else { $this->changes['frequencyRules']['removed'][] = $val; } } elseif ( $prop == 'stage' ) { if ( $current && !$val ) { $this->changes['stage'] = [$current->getId(), $val ]; } elseif ( !$current && $val ) { $this->changes['stage'] = [$current, $val->getId() ]; } elseif ( $current && $val && $current->getId() != $val->getId() ) { $this->changes['stage'] = [$current->getId(), $val->getId() ]; } } elseif ( $this->$getter() != $val ) { $this->changes[$prop] = [ $this->$getter(), $val ]; } }
when I changed code to
Code:
protected function isChanged($prop, $val, $oldValue = null) { $getter = 'get' . ucfirst($prop); $current = ($oldValue) ? $oldValue : $this->$getter(); if ( $prop == 'owner' ) { if ( $current && !$val ) { $this->changes['owner'] = [$current->getId(), $val ]; } elseif ( !$current && $val ) { $this->changes['owner'] = [$current, $val->getId() ]; } elseif ( $current && $val && $current->getId() != $val->getId() ) { $this->changes['owner'] = [$current->getId(), $val->getId() ]; } } elseif ( $prop == 'ipAddresses' ) { $this->changes['ipAddresses'] = ['', $val->getIpAddress() ]; } elseif ( $prop == 'tags' ) { if ( $val instanceof Tag ) { $this->changes['tags']['added'][] = $val->getTag(); } else { $this->changes['tags']['removed'][] = $val; } } elseif ( $prop == 'utmtags' ) { if ( $val instanceof UtmTag ) { if ( $val->getUtmContent() ) { $this->changes['utmtags'] = ['utm_content', $val->getUtmContent() ]; } if ( $val->getUtmMedium() ) { $this->changes['utmtags'] = ['utm_medium', $val->getUtmMedium() ]; } if ( $val->getUtmCampaign() ) { $this->changes['utmtags'] = ['utm_campaign', $val->getUtmCampaign() ]; } if ( $val->getUtmTerm() ) { $this->changes['utmtags'] = ['utm_term', $val->getUtmTerm() ]; } if ( $val->getUtmSource() ) { $this->changes['utmtags'] = ['utm_source', $val->getUtmSource() ]; } } } elseif ( $prop == 'frequencyRules' ) { if ( $val instanceof FrequencyRule ) { if ( $val->getFrequencyTime() ) { $this->changes['frequencyRules'] = ['frequency_time', $val->getFrequencyTime() ]; } if ( $val->getFrequencyNumber() ) { $this->changes['frequencyRules'] = ['frequency_number', $val->getFrequencyNumber() ]; } } else { $this->changes['frequencyRules']['removed'][] = $val; } } elseif ( $prop == 'stage' ) { if ( $current && !$val ) { $this->changes['stage'] = [$current->getId(), $val ]; } elseif ( !$current && $val ) { $this->changes['stage'] = [$current, $val->getId() ]; } elseif ( $current && $val && $current->getId() != $val->getId() ) { $this->changes['stage'] = [$current->getId(), $val->getId() ]; } } elseif ( $oldValue != $val ) { //changed line $this->changes[$prop] = [$oldValue, $val ]; //changed line } }
event LeadEvents::LEAD_POINTS_CHANGE start correct

I have problem with start event LeadEvents::LEAD_POINTS_CHANGE on mautic 2.5.1 in my plugin.
After research I find place in code where code should change in file app/bundles/LeadBundle/Entity/Lead.php in method isChanged now is

protected function isChanged($prop, $val, $oldValue = null) { $getter = 'get' . ucfirst($prop); $current = ($oldValue) ? $oldValue : $this->$getter(); if ( $prop == 'owner' ) { if ( $current && !$val ) { $this->changes['owner'] = [$current->getId(), $val ]; } elseif ( !$current && $val ) { $this->changes['owner'] = [$current, $val->getId() ]; } elseif ( $current && $val && $current->getId() != $val->getId() ) { $this->changes['owner'] = [$current->getId(), $val->getId() ]; } } elseif ( $prop == 'ipAddresses' ) { $this->changes['ipAddresses'] = ['', $val->getIpAddress() ]; } elseif ( $prop == 'tags' ) { if ( $val instanceof Tag ) { $this->changes['tags']['added'][] = $val->getTag(); } else { $this->changes['tags']['removed'][] = $val; } } elseif ( $prop == 'utmtags' ) { if ( $val instanceof UtmTag ) { if ( $val->getUtmContent() ) { $this->changes['utmtags'] = ['utm_content', $val->getUtmContent() ]; } if ( $val->getUtmMedium() ) { $this->changes['utmtags'] = ['utm_medium', $val->getUtmMedium() ]; } if ( $val->getUtmCampaign() ) { $this->changes['utmtags'] = ['utm_campaign', $val->getUtmCampaign() ]; } if ( $val->getUtmTerm() ) { $this->changes['utmtags'] = ['utm_term', $val->getUtmTerm() ]; } if ( $val->getUtmSource() ) { $this->changes['utmtags'] = ['utm_source', $val->getUtmSource() ]; } } } elseif ( $prop == 'frequencyRules' ) { if ( $val instanceof FrequencyRule ) { if ( $val->getFrequencyTime() ) { $this->changes['frequencyRules'] = ['frequency_time', $val->getFrequencyTime() ]; } if ( $val->getFrequencyNumber() ) { $this->changes['frequencyRules'] = ['frequency_number', $val->getFrequencyNumber() ]; } } else { $this->changes['frequencyRules']['removed'][] = $val; } } elseif ( $prop == 'stage' ) { if ( $current && !$val ) { $this->changes['stage'] = [$current->getId(), $val ]; } elseif ( !$current && $val ) { $this->changes['stage'] = [$current, $val->getId() ]; } elseif ( $current && $val && $current->getId() != $val->getId() ) { $this->changes['stage'] = [$current->getId(), $val->getId() ]; } } elseif ( $this->$getter() != $val ) { $this->changes[$prop] = [ $this->$getter(), $val ]; } }
when I changed code to

protected function isChanged($prop, $val, $oldValue = null) { $getter = 'get' . ucfirst($prop); $current = ($oldValue) ? $oldValue : $this->$getter(); if ( $prop == 'owner' ) { if ( $current && !$val ) { $this->changes['owner'] = [$current->getId(), $val ]; } elseif ( !$current && $val ) { $this->changes['owner'] = [$current, $val->getId() ]; } elseif ( $current && $val && $current->getId() != $val->getId() ) { $this->changes['owner'] = [$current->getId(), $val->getId() ]; } } elseif ( $prop == 'ipAddresses' ) { $this->changes['ipAddresses'] = ['', $val->getIpAddress() ]; } elseif ( $prop == 'tags' ) { if ( $val instanceof Tag ) { $this->changes['tags']['added'][] = $val->getTag(); } else { $this->changes['tags']['removed'][] = $val; } } elseif ( $prop == 'utmtags' ) { if ( $val instanceof UtmTag ) { if ( $val->getUtmContent() ) { $this->changes['utmtags'] = ['utm_content', $val->getUtmContent() ]; } if ( $val->getUtmMedium() ) { $this->changes['utmtags'] = ['utm_medium', $val->getUtmMedium() ]; } if ( $val->getUtmCampaign() ) { $this->changes['utmtags'] = ['utm_campaign', $val->getUtmCampaign() ]; } if ( $val->getUtmTerm() ) { $this->changes['utmtags'] = ['utm_term', $val->getUtmTerm() ]; } if ( $val->getUtmSource() ) { $this->changes['utmtags'] = ['utm_source', $val->getUtmSource() ]; } } } elseif ( $prop == 'frequencyRules' ) { if ( $val instanceof FrequencyRule ) { if ( $val->getFrequencyTime() ) { $this->changes['frequencyRules'] = ['frequency_time', $val->getFrequencyTime() ]; } if ( $val->getFrequencyNumber() ) { $this->changes['frequencyRules'] = ['frequency_number', $val->getFrequencyNumber() ]; } } else { $this->changes['frequencyRules']['removed'][] = $val; } } elseif ( $prop == 'stage' ) { if ( $current && !$val ) { $this->changes['stage'] = [$current->getId(), $val ]; } elseif ( !$current && $val ) { $this->changes['stage'] = [$current, $val->getId() ]; } elseif ( $current && $val && $current->getId() != $val->getId() ) { $this->changes['stage'] = [$current->getId(), $val->getId() ]; } } elseif ( $oldValue != $val ) { //changed line $this->changes[$prop] = [$oldValue, $val ]; //changed line } }
event LeadEvents::LEAD_POINTS_CHANGE start correct