|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Sonata Project package. |
|
7
|
|
|
* |
|
8
|
|
|
* (c) Thomas Rabaix <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Sonata\NotificationBundle\Event; |
|
15
|
|
|
|
|
16
|
|
|
use Sonata\NotificationBundle\Backend\BackendInterface; |
|
17
|
|
|
use Sonata\NotificationBundle\Iterator\MessageIteratorInterface; |
|
18
|
|
|
use Sonata\NotificationBundle\Model\MessageInterface; |
|
19
|
|
|
use Symfony\Contracts\EventDispatcher\Event; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Event for ConsumerHandlerCommand iterations event. |
|
23
|
|
|
* |
|
24
|
|
|
* @author Kevin Nedelec <[email protected]> |
|
25
|
|
|
*/ |
|
26
|
|
|
class IterateEvent extends Event |
|
27
|
|
|
{ |
|
28
|
|
|
public const EVENT_NAME = 'sonata.notification.event.message_iterate_event'; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var MessageIteratorInterface |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $iterator; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var BackendInterface |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $backend; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var MessageInterface |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $message; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param BackendInterface $backend |
|
47
|
|
|
* @param MessageInterface $message |
|
48
|
|
|
*/ |
|
49
|
|
|
public function __construct(MessageIteratorInterface $iterator, ?BackendInterface $backend = null, ?MessageInterface $message = null) |
|
50
|
|
|
{ |
|
51
|
|
|
$this->iterator = $iterator; |
|
52
|
|
|
$this->backend = $backend; |
|
53
|
|
|
$this->message = $message; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return BackendInterface |
|
58
|
|
|
*/ |
|
59
|
|
|
public function getBackend() |
|
60
|
|
|
{ |
|
61
|
|
|
return $this->backend; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return MessageIteratorInterface |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getIterator() |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->iterator; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return MessageInterface |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getMessage() |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->message; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|