forked from FriendsOfSymfony/FOSMessageBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AbstractMessageBuilder.php
71 lines (60 loc) · 1.45 KB
/
AbstractMessageBuilder.php
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
<?php
namespace FOS\MessageBundle\MessageBuilder;
use FOS\MessageBundle\Model\MessageInterface;
use FOS\MessageBundle\Model\ParticipantInterface;
use FOS\MessageBundle\Model\ThreadInterface;
/**
* Fluent interface message builder
*
* @author Thibault Duplessis <[email protected]>
*/
abstract class AbstractMessageBuilder
{
/**
* The message we are building
*
* @var MessageInterface
*/
protected $message;
/**
* The thread the message goes in
*
* @var ThreadInterface
*/
protected $thread;
public function __construct(MessageInterface $message, ThreadInterface $thread)
{
$this->message = $message;
$this->thread = $thread;
$this->message->setThread($thread);
$thread->addMessage($message);
}
/**
* Gets the created message.
*
* @return MessageInterface the message created
*/
public function getMessage()
{
return $this->message;
}
/**
* @param string
* @return MessageBuilder (fluent interface)
*/
public function setBody($body)
{
$this->message->setBody($body);
return $this;
}
/**
* @param ParticipantInterface
* @return MessageBuilder (fluent interface)
*/
public function setSender(ParticipantInterface $sender)
{
$this->message->setSender($sender);
$this->thread->addParticipant($sender);
return $this;
}
}