Spaces:
No application file
No application file
File size: 4,633 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
<?php
namespace Mautic\CampaignBundle\Event;
use Mautic\CampaignBundle\Entity\LeadEventLog;
use Mautic\LeadBundle\Entity\Lead;
use Symfony\Contracts\EventDispatcher\Event;
/**
* @deprecated 2.13.0; to be removed in 3.0
*/
class CampaignExecutionEvent extends Event
{
use EventArrayTrait;
use ContextTrait;
/**
* @var Lead
*/
protected $lead;
/**
* @var array
*/
protected $event;
/**
* @var array
*/
protected $eventDetails;
/**
* @var bool
*/
protected $systemTriggered;
/**
* @var array
*/
protected $eventSettings;
/**
* @var bool
*/
protected $logUpdatedByListener = false;
/**
* @var string
*/
protected $channel;
/**
* @var int
*/
protected $channelId;
/**
* @param bool|mixed[]|string|null $result
*/
public function __construct(
array $args,
protected $result,
protected ?LeadEventLog $log = null
) {
$this->lead = $args['lead'];
$this->event = $args['event'];
$this->eventDetails = $args['eventDetails'];
$this->systemTriggered = $args['systemTriggered'];
$this->eventSettings = $args['eventSettings'];
}
/**
* @return Lead
*/
public function getLead()
{
return $this->lead;
}
/**
* Returns array with lead fields and owner ID if exist.
*
* @return array
*/
public function getLeadFields()
{
$lead = $this->getLead();
$isLeadEntity = $lead instanceof Lead;
// In case Lead is a scalar value:
if (!$isLeadEntity && !is_array($lead)) {
$lead = [];
}
$leadFields = $isLeadEntity ? $lead->getProfileFields() : $lead;
$leadFields['owner_id'] = $isLeadEntity && ($owner = $lead->getOwner()) ? $owner->getId() : 0;
return $leadFields;
}
/**
* @return array
*/
public function getEvent()
{
return ($this->event instanceof \Mautic\CampaignBundle\Entity\Event) ? $this->getEventArray($this->event) : $this->event;
}
/**
* @return array
*/
public function getConfig()
{
return $this->getEvent()['properties'];
}
/**
* @return array
*/
public function getEventDetails()
{
return $this->eventDetails;
}
/**
* @return bool
*/
public function getSystemTriggered()
{
return $this->systemTriggered;
}
/**
* @return bool|mixed[]|string|null
*/
public function getResult()
{
return $this->result;
}
/**
* @param bool|mixed[]|string|null $result
*
* @return $this
*/
public function setResult($result)
{
$this->result = $result;
return $this;
}
/**
* Set the result to failed.
*
* @param string|null $reason
*
* @return $this
*/
public function setFailed($reason = null)
{
$this->result = [
'failed' => 1,
'reason' => $reason,
];
return $this;
}
/**
* @return mixed
*/
public function getEventSettings()
{
return $this->eventSettings;
}
/**
* Set a custom log entry to override auto-handling of the log entry.
*
* @return $this
*/
public function setLogEntry(LeadEventLog $log)
{
$this->logUpdatedByListener = true;
$this->log = $log;
return $this;
}
/**
* @return LeadEventLog
*/
public function getLogEntry()
{
return $this->log;
}
/**
* Returns if a listener updated the log entry.
*
* @return bool
*/
public function wasLogUpdatedByListener()
{
return $this->logUpdatedByListener;
}
/**
* @param string $channel
* @param string|int|null $channelId
*/
public function setChannel($channel, $channelId = null): void
{
if (null !== $this->log) {
// Set the channel since we have the resource
$this->log->setChannel($channel);
$this->log->setChannelId($channelId);
}
$this->channel = $channel;
$this->channelId = $channelId;
}
/**
* @return mixed
*/
public function getChannel()
{
return $this->channel;
}
/**
* @return mixed
*/
public function getChannelId()
{
return $this->channelId;
}
}
|