|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2014 Underground Elephant |
|
5
|
|
|
* |
|
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
7
|
|
|
* you may not use this file except in compliance with the License. |
|
8
|
|
|
* You may obtain a copy of the License at |
|
9
|
|
|
* |
|
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11
|
|
|
* |
|
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
|
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
|
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15
|
|
|
* See the License for the specific language governing permissions and |
|
16
|
|
|
* limitations under the License. |
|
17
|
|
|
* |
|
18
|
|
|
* @package qpush-bundle |
|
19
|
|
|
* @copyright Underground Elephant 2014 |
|
20
|
|
|
* @license Apache License, Version 2.0 |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
namespace Uecode\Bundle\QPushBundle\Event; |
|
24
|
|
|
|
|
25
|
|
|
use Symfony\Component\EventDispatcher\Event; |
|
26
|
|
|
use Uecode\Bundle\QPushBundle\Message\Notification; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @author Keith Kirk <[email protected]> |
|
30
|
|
|
*/ |
|
31
|
|
|
class NotificationEvent extends Event |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* A Subscription Notification Type |
|
35
|
|
|
*/ |
|
36
|
|
|
const TYPE_SUBSCRIPTION = 'SubscriptionNotification'; |
|
37
|
|
|
/** |
|
38
|
|
|
* A Message Notification Type |
|
39
|
|
|
*/ |
|
40
|
|
|
const TYPE_MESSAGE = 'MessageNotification'; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Queue name |
|
44
|
|
|
* |
|
45
|
|
|
* @var string |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $queueName; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Notification Type |
|
51
|
|
|
* |
|
52
|
|
|
* @var string |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $type; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Notification |
|
58
|
|
|
* |
|
59
|
|
|
* @var array |
|
60
|
|
|
*/ |
|
61
|
|
|
protected $notification; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Constructor |
|
65
|
|
|
* |
|
66
|
|
|
* @param string $queueName The Queue Name |
|
67
|
|
|
* @param string $type The Notification Type |
|
68
|
|
|
* @param Notification $notification The Notification |
|
69
|
|
|
*/ |
|
70
|
|
|
public function __construct($queueName, $type, Notification $notification) |
|
71
|
|
|
{ |
|
72
|
|
|
if (!in_array($type, [self::TYPE_SUBSCRIPTION, self::TYPE_MESSAGE])) { |
|
73
|
|
|
throw new \InvalidArgumentException( |
|
74
|
|
|
sprintf("Invalid notification type given! (%s)", $type) |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
$this->queueName = $queueName; |
|
79
|
|
|
$this->type = $type; |
|
80
|
|
|
$this->notification = $notification; |
|
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Returns the Queue name |
|
85
|
|
|
* |
|
86
|
|
|
* return string |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getQueueName() |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->queueName; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Returns the Notification Type |
|
95
|
|
|
* |
|
96
|
|
|
* @return string |
|
97
|
|
|
*/ |
|
98
|
|
|
public function getType() |
|
99
|
|
|
{ |
|
100
|
|
|
return $this->type; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Returns the Notification |
|
105
|
|
|
* |
|
106
|
|
|
* return array |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getNotification() |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->notification; |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..