190 lines
3.0 KiB
PHP
190 lines
3.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: ondra
|
|
* Date: 1.2.18
|
|
* Time: 15:38.
|
|
*/
|
|
|
|
namespace KupShop\KupShopBundle\Event;
|
|
|
|
use KupShop\KupShopBundle\Email\BaseEmail;
|
|
use Symfony\Contracts\EventDispatcher\Event;
|
|
|
|
class EmailEvent extends Event
|
|
{
|
|
public const SEND = 'kupshop.email.send';
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $message;
|
|
|
|
/** @var BaseEmail */
|
|
protected $service;
|
|
|
|
protected ?string $messageId = null;
|
|
|
|
public function __construct($message, $service)
|
|
{
|
|
$this->message = $message;
|
|
$this->service = $service;
|
|
}
|
|
|
|
/**
|
|
* @param $subject string
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setSubject($subject)
|
|
{
|
|
$this->message['subject'] = $subject;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param $from string
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setFrom($from)
|
|
{
|
|
$this->message['from'] = $from;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param $to string
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setTo($to)
|
|
{
|
|
$this->message['to'] = $to;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param $body string
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setBody($body)
|
|
{
|
|
$this->message['body'] = $body;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param $attachments array|null
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setAttachments($attachments)
|
|
{
|
|
$this->message['attachments'] = $attachments;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param $type string
|
|
*
|
|
* @return $this
|
|
*/
|
|
public function setType($type)
|
|
{
|
|
$this->message['type'] = $type;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return $this
|
|
*/
|
|
public function setMessage($message)
|
|
{
|
|
$this->message = $message;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function setMessageId(string $messageId): self
|
|
{
|
|
$this->messageId = $messageId;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getSubject()
|
|
{
|
|
return $this->message['subject'];
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getFrom()
|
|
{
|
|
return $this->message['from'];
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getTo()
|
|
{
|
|
return $this->message['to'];
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getBody()
|
|
{
|
|
return $this->message['body'];
|
|
}
|
|
|
|
/**
|
|
* @return array|null
|
|
*/
|
|
public function getAttachments()
|
|
{
|
|
return $this->message['attachments'];
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getType()
|
|
{
|
|
return $this->message['type'];
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function getMessage()
|
|
{
|
|
return $this->message;
|
|
}
|
|
|
|
public function getService(): BaseEmail
|
|
{
|
|
return $this->service;
|
|
}
|
|
|
|
public function getMessageId(): ?string
|
|
{
|
|
return $this->messageId;
|
|
}
|
|
}
|