1: <?php
2:
3: /**
4: * Avisota newsletter and mailing system
5: *
6: * PHP Version 5.3
7: *
8: * @copyright bit3 UG 2013
9: * @author Tristan Lins <tristan.lins@bit3.de>
10: * @package avisota-core
11: * @license LGPL-3.0+
12: * @link http://avisota.org
13: */
14:
15: namespace Avisota\Event;
16:
17: use Avisota\Message\MessageInterface;
18: use Avisota\Queue\EventEmittingQueueInterface;
19: use Avisota\Queue\QueueInterface;
20: use Symfony\Component\EventDispatcher\Event;
21:
22: /**
23: * Abstract event triggered by an
24: * {@link http://avisota.github.io/core/class-Avisota.Queue.EventEmittingQueueInterface.html
25: * event emitting queue}.
26: *
27: * @package avisota-core
28: */
29: class PreEnqueueEvent extends Event
30: {
31: const NAME = 'avisota.queue.pre-enqueue';
32:
33: /**
34: * The message to be transported.
35: *
36: * @var MessageInterface
37: */
38: protected $message;
39:
40: /**
41: * The queue that send the message.
42: *
43: * @var QueueInterface
44: */
45: protected $queue;
46:
47: /**
48: * Skip the message and do not enqueue.
49: *
50: * @var boolean
51: */
52: protected $skip = false;
53:
54: public function __construct(MessageInterface $message, QueueInterface $queue)
55: {
56: $this->message = $message;
57: $this->queue = $queue;
58: }
59:
60: /**
61: * Get the message to be transported.
62: *
63: * @return \Avisota\Message\MessageInterface
64: */
65: public function getMessage()
66: {
67: return $this->message;
68: }
69:
70: /**
71: * Get the transporting queue.
72: *
73: * @return QueueInterface
74: */
75: public function getQueue()
76: {
77: return $this->queue;
78: }
79:
80: /**
81: * Set if the message should be skipped.
82: *
83: * @param boolean $skip
84: */
85: public function setSkip($skip)
86: {
87: $this->skip = (bool) $skip;
88: return $this;
89: }
90:
91: /**
92: * Determines if the message should be skipped.
93: *
94: * @return boolean
95: */
96: public function isSkip()
97: {
98: return $this->skip;
99: }
100: }