1 | <?php |
||
18 | class Notifications_Task extends \ElkArte\ValuesContainer |
||
19 | { |
||
20 | /** |
||
21 | * Data of the members to notify. |
||
22 | * Populated only if the getMembersData method is called. |
||
23 | * |
||
24 | * @var mixed[] |
||
25 | */ |
||
26 | protected $_members_data = null; |
||
27 | |||
28 | /** |
||
29 | * Data of the member generating the notification. |
||
30 | * Populated only if the getNotifierData method is called. |
||
31 | * |
||
32 | * @var mixed[] |
||
33 | */ |
||
34 | protected $_notifier_data = null; |
||
35 | |||
36 | /** |
||
37 | * The constructor prepared the data array and fills some default values |
||
38 | * if needed. |
||
39 | * |
||
40 | * @param string $type The notification type we are dealing with |
||
41 | * @param int $id The id of the target (can be a message, a topic, a member, whatever) |
||
42 | * @param int $id_member The id of the member generating the notification |
||
43 | * @param mixed[] $data An array of data that can be necessary in the process |
||
44 | * @param string $namespace A namespace for the class if different from the |
||
45 | * default \ElkArte\sources\subs\MentionType\ |
||
46 | */ |
||
47 | 2 | public function __construct($type, $id, $id_member, $data, $namespace = '') |
|
48 | { |
||
49 | 2 | parent::__construct(); |
|
50 | |||
51 | 2 | $this->data = array( |
|
|
|||
52 | 2 | 'notification_type' => $type, |
|
53 | 2 | 'namespace' => empty($namespace) ? '\\ElkArte\\sources\\subs\\MentionType\\' : rtrim($namespace, '\\') . '\\', |
|
54 | 2 | 'id_target' => $id, |
|
55 | 2 | 'id_member_from' => $id_member, |
|
56 | 2 | 'source_data' => $data, |
|
57 | 2 | 'log_time' => time() |
|
58 | ); |
||
59 | |||
60 | 2 | if (!isset($this->data['source_data']['status'])) |
|
61 | 2 | $this->data['source_data']['status'] = 'new'; |
|
62 | |||
63 | 2 | if (isset($this->data['source_data']['id_members'])) |
|
64 | 2 | $this->setMembers($this->data['source_data']['id_members']); |
|
65 | else |
||
66 | $this->setMembers(array()); |
||
67 | 2 | } |
|
68 | |||
69 | /** |
||
70 | * Returns the array of member that have to receive the notification. |
||
71 | * |
||
72 | * @return int[] An array of member id |
||
73 | */ |
||
74 | 2 | public function getMembers() |
|
78 | |||
79 | /** |
||
80 | * Sets the members that have to receive the notification. |
||
81 | * |
||
82 | * @param int|int[] An array of member id |
||
83 | */ |
||
84 | 2 | public function setMembers($members) |
|
88 | |||
89 | /** |
||
90 | * Returns the data from getBasicMemberData about the members to be notified. |
||
91 | * |
||
92 | * @return mixed[] |
||
93 | */ |
||
94 | 2 | public function getMembersData() |
|
95 | { |
||
96 | 2 | if ($this->_members_data === null) |
|
97 | { |
||
98 | 2 | require_once(SUBSDIR . '/Members.subs.php'); |
|
99 | 2 | $this->_members_data = getBasicMemberData($this->getMembers(), array('preferences' => true)); |
|
100 | } |
||
101 | |||
102 | 2 | return $this->_members_data; |
|
103 | } |
||
104 | |||
105 | /** |
||
106 | * Returns the data from getBasicMemberData about the member that |
||
107 | * generated the notification |
||
108 | * |
||
109 | * @return mixed[] |
||
110 | */ |
||
111 | public function getNotifierData() |
||
112 | { |
||
113 | if ($this->_notifier_data === null) |
||
114 | { |
||
115 | require_once(SUBSDIR . '/Members.subs.php'); |
||
116 | $this->_notifier_data = getBasicMemberData($this->id_member_from); |
||
117 | } |
||
118 | |||
119 | return $this->_notifier_data; |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * Returns the class name of the MentionType. |
||
124 | * |
||
125 | * @return string |
||
126 | */ |
||
127 | 2 | public function getClass() |
|
131 | } |
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..