Completed
Branch BUG-9623-config-log (c144cd)
by
unknown
18:38
created

EE_Messages_Processor   C

Complexity

Total Complexity 62

Size/Duplication

Total Lines 514
Duplicated Lines 0.78 %

Coupling/Cohesion

Components 1
Dependencies 13

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 4
loc 514
rs 5.9493
wmc 62
lcom 1
cbo 13

21 Methods

Rating   Name   Duplication   Size   Complexity  
A queue_for_generation() 0 5 2
B generate_for_preview() 0 26 5
A __construct() 0 4 1
A _init_queue_and_generator() 0 4 1
A get_queue() 0 3 1
A batch_generate_from_queue() 0 13 3
C _build_queue_for_generation() 0 25 7
B _build_queue_for_sending() 0 19 5
A batch_send_from_queue() 0 13 3
A generate_and_return() 0 5 1
A generate_queue() 0 3 1
A batch_queue_for_generation_and_persist() 0 5 1
A batch_queue_for_generation_no_persist() 0 4 1
B _queue_for_generation_loop() 0 12 5
A generate_and_queue_for_sending() 0 5 1
A queue_for_sending() 0 14 3
B generate_and_send_now() 0 33 6
A generate_for_all_active_messengers() 0 9 2
A setup_mtgs_for_all_active_messengers() 0 10 3
A setup_messages_from_ids_and_send() 0 18 3
C setup_messages_to_generate_from_registration_ids_in_request() 4 35 7

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like EE_Messages_Processor often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use EE_Messages_Processor, and based on these observations, apply Extract Interface, too.

1
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
3
/**
4
 * This class contains all business logic related to generating, queuing, and scheduling of
5
 * messages in the EE_messages system.
6
 *
7
 * @package    Event Espresso
8
 * @subpackage messages
9
 * @author     Darren Ethier
10
 * @since      4.9.0
11
 */
12
class EE_Messages_Processor {
13
14
15
	/**
16
	 * @type EE_Message_Resource_Manager $_message_resource_manager
17
	 */
18
	protected $_message_resource_manager;
19
20
	/**
21
	 * @type EE_Messages_Queue
22
	 */
23
	protected $_queue;
24
25
	/**
26
	 * @type  EE_Messages_Generator
27
	 */
28
	protected $_generator;
29
30
31
32
33
	/**
34
	 * constructor
35
	 *
36
	 * @param EE_Message_Resource_Manager $message_resource_manager
37
	 */
38
	public function __construct( EE_Message_Resource_Manager $message_resource_manager ) {
39
		$this->_message_resource_manager = $message_resource_manager;
40
		$this->_init_queue_and_generator();
41
	}
42
43
44
45
46
	/**
47
	 * This method sets (or resets) the various properties for use.
48
	 *
49
	 * - $_queue = holds the messages queue
50
	 * - $_generator = holds the messages generator
51
	 */
52
	protected function _init_queue_and_generator() {
53
		$this->_generator = EE_Registry::factory( 'EE_Messages_Generator' );
54
		$this->_queue = $this->_generator->generation_queue();
55
	}
56
57
58
59
60
	/**
61
	 * This returns the current set queue.
62
	 * @return EE_Messages_Queue
63
	 */
64
	public function get_queue() {
65
		return $this->_queue;
66
	}
67
68
69
	/**
70
	 * Calls the EE_Messages_Queue::get_batch_to_generate() method and sends to EE_Messages_Generator.
71
	 *
72
	 * @param  EE_Message[] $messages    Array of EE_Message objects (optional) to build the queue with.
73
	 * @param  bool         $clear_queue Whether to ensure a fresh queue or not.
74
	 *
75
	 * @return bool|EE_Messages_Queue return false if nothing generated.  This returns a new EE_Message_Queue with
76
	 *                                   generated messages.
77
	 */
78
	public function batch_generate_from_queue( $messages = array(), $clear_queue = false ) {
79
		if ( $this->_build_queue_for_generation( $messages, $clear_queue ) ) {
80
			$new_queue = $this->_generator->generate();
81
			if ( $new_queue instanceof EE_Messages_Queue ) {
82
				//unlock queue
83
				$this->_queue->unlock_queue();
84
				$this->_queue->initiate_request_by_priority( 'send' );
85
				return $new_queue;
86
			}
87
		}
88
		$this->_queue->unlock_queue();
89
		return false;
90
	}
91
92
93
94
	/**
95
	 * This method preps a queue for generation.
96
	 *
97
	 * @since    4.9.0
98
	 *
99
	 * @param EE_Message[] $messages    Array of EE_Message objects to build the queue with
100
	 *
101
	 * @param   bool       $clear_queue This indicates whether the existing queue should be dumped or not.
102
	 *
103
	 * @return bool true means queue prepped, false means there was a lock so no generation please.
104
	 */
105
	protected function _build_queue_for_generation( $messages = array(), $clear_queue = false ) {
106
107
		if ( $clear_queue ) {
108
			$this->_init_queue_and_generator();
109
		}
110
111
		if ( $messages ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $messages of type EE_Message[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
112
			//if generation is locked then get out now because that means processing is already happening.
113
			if ( $this->_queue->is_locked() ) {
114
				return false;
115
			}
116
117
			$this->_queue->lock_queue();
118
			$messages = is_array( $messages ) ? $messages : array( $messages );
119
			foreach ( $messages as $message ) {
120
				if ( $message instanceof EE_Message ) {
121
					$data = $message->all_extra_meta_array();
122
					$this->_queue->add( $message, $data );
123
				}
124
			}
125
			return true;
126
		} else {
127
			return $this->_queue->get_batch_to_generate();
128
		}
129
	}
130
131
132
	/**
133
	 * This method preps a queue for sending.
134
	 *
135
	 * @param EE_Message[] $messages
136
	 * @param bool  $clear_queue Used to indicate whether to start with a fresh queue or not.
137
	 *
138
	 * @return bool true means queue prepped, false means there was a lock so no queue prepped.
139
	 */
140
	protected function _build_queue_for_sending( $messages, $clear_queue = false ) {
141
		//if sending is locked then get out now because that means processing is already happening.
142
		if ( $this->_queue->is_locked( EE_Messages_Queue::action_sending ) ) {
143
			return false;
144
		}
145
146
		$this->_queue->lock_queue( EE_Messages_Queue::action_sending );
147
148
		if ( $clear_queue ) {
149
			$this->_init_queue_and_generator();
150
		}
151
152
		$messages = is_array( $messages ) ? $messages : array( $messages );
153
154
		foreach ( $messages as $message ) {
155
			$this->_queue->add( $message );
156
		}
157
		return true;
158
	}
159
160
161
	/**
162
	 * Calls the EE_Message_Queue::get_to_send_batch_and_send() method and then immediately just calls EE_Message_Queue::execute()
163
	 * to iterate and send unsent messages.
164
	 *
165
	 * @param EE_Message[] $messages    If an array of messages is sent in then use it.
166
	 *
167
	 * @param bool         $clear_queue Whether to initialize a new queue or keep the existing one.
168
	 *
169
	 * @return EE_Messages_Queue
170
	 */
171
	public function batch_send_from_queue( $messages = array(), $clear_queue = false ) {
172
173
		if ( $messages && $this->_build_queue_for_sending( $messages, $clear_queue ) ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $messages of type EE_Message[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
174
			$this->_queue->execute();
175
			$this->_queue->unlock_queue( EE_Messages_Queue::action_sending );
176
		} else {
177
			//get messages to send and execute.
178
			$this->_queue->get_to_send_batch_and_send();
179
		}
180
		//note: callers can use the EE_Messages_Queue::count_STS_in_queue() method to find out if there were any failed
181
		//messages in the queue and decide how to handle at that point.
182
		return $this->_queue;
183
	}
184
185
186
187
188
189
190
	/**
191
	 * This immediately generates messages using the given array of EE_Message_To_Generate objects and returns the
192
	 * EE_Message_Queue with the generated messages for the caller to work with.  Note, this does NOT save the generated
193
	 * messages in the queue, leaving it up to the caller to do so.
194
	 *
195
	 * @param EE_Message_To_Generate[] $messages_to_generate
196
	 * @return EE_Messages_Queue
197
	 */
198
	public function generate_and_return(  $messages_to_generate ) {
199
		$this->_init_queue_and_generator();
200
		$this->_queue_for_generation_loop( $messages_to_generate );
201
		return $this->_generator->generate( false );
202
	}
203
204
205
206
207
	/**
208
	 * Executes the generator generate method on the current internal queue, and returns the generated queue.
209
	 * @param  bool     $persist    Indicate whether to instruct the generator to persist the generated queue (true) or not (false).
210
	 * @return EE_Messages_Queue
211
	 */
212
	public function generate_queue( $persist = true ) {
213
		return $this->_generator->generate( $persist );
214
	}
215
216
217
218
219
	/**
220
	 * Queue for generation.  Note this does NOT persist to the db.  Client code should call get_message_repository()->save() if desire
221
	 * to persist.  This method is provided to client code to decide what it wants to do with queued messages for generation.
222
	 * @param EE_Message_To_Generate $message_to_generate
223
	 * @param bool                   $test_send             Whether this item is for a test send or not.
224
	 * @return  EE_Messages_Queue
225
	 */
226
	public function queue_for_generation( EE_Message_To_Generate $message_to_generate, $test_send = false ) {
227
		if ( $message_to_generate->valid() ) {
228
			$this->_generator->create_and_add_message_to_queue( $message_to_generate, $test_send );
229
		}
230
	}
231
232
233
234
235
236
237
238
	/**
239
	 * This receives an array of EE_Message_To_Generate objects, converts them to EE_Message adds them to the generation queue
240
	 * and then persists to storage.
241
	 *
242
	 * @param EE_Message_To_Generate[] $messages_to_generate
243
	 */
244
	public function batch_queue_for_generation_and_persist( $messages_to_generate ) {
245
		$this->_init_queue_and_generator();
246
		$this->_queue_for_generation_loop( $messages_to_generate );
247
		$this->_queue->save();
248
	}
249
250
251
252
253
254
255
	/**
256
	 * This receives an array of EE_Message_To_Generate objects, converts them to EE_Message and adds them to the generation
257
	 * queue.  Does NOT persist to storage (unless there is an error.
258
	 * Client code can retrieve the generated queue by calling EEM_Messages_Processor::get_queue()
259
	 *
260
	 * @param EE_Message_To_Generate[]  $messages_to_generate
261
	 */
262
	public function batch_queue_for_generation_no_persist( $messages_to_generate ) {
263
		$this->_init_queue_and_generator();
264
		$this->_queue_for_generation_loop( $messages_to_generate );
265
	}
266
267
268
269
270
	/**
271
	 * Simply loops through the given array of EE_Message_To_Generate objects and adds them to the _queue as EE_Message
272
	 * objects.
273
	 *
274
	 * @param EE_Message_To_Generate[] $messages_to_generate
275
	 */
276
	protected function _queue_for_generation_loop( $messages_to_generate ) {
277
		//make sure is in an array.
278
		if ( ! is_array( $messages_to_generate ) ) {
279
			$messages_to_generate = array( $messages_to_generate );
280
		}
281
282
		foreach ( $messages_to_generate as $message_to_generate ) {
283
			if ( $message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid() ) {
284
				$this->queue_for_generation( $message_to_generate );
285
			}
286
		}
287
	}
288
289
290
291
292
293
	/**
294
	 * Receives an array of EE_Message_To_Generate objects and generates the EE_Message objects, then persists (so its
295
	 * queued for sending).
296
	 * @param  EE_Message_To_Generate[]
297
	 * @return EE_Messages_Queue
298
	 */
299
	public function generate_and_queue_for_sending( $messages_to_generate ) {
300
		$this->_init_queue_and_generator();
301
		$this->_queue_for_generation_loop( $messages_to_generate );
302
		return $this->_generator->generate( true );
303
	}
304
305
306
307
308
309
	/**
310
	 * Generate for preview and execute right away.
311
	 *
312
	 * @param   EE_Message_To_Generate $message_to_generate
313
	 * @param   bool                   $test_send                Whether this is a test send or not.
314
	 * @return  EE_Messages_Queue | bool   false if unable to generate otherwise the generated queue.
315
	 */
316
	public function generate_for_preview( EE_Message_To_Generate $message_to_generate, $test_send = false ) {
317
		if ( ! $message_to_generate->valid() ) {
318
			EE_Error::add_error(
319
				__( 'Unable to generate preview because of invalid data', 'event_espresso' ),
320
				__FILE__,
321
				__FUNCTION__,
322
				__LINE__
323
			);
324
			return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by EE_Messages_Processor::generate_for_preview of type EE_Messages_Queue.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
325
		}
326
		//just make sure preview is set on the $message_to_generate (in case client forgot)
327
		$message_to_generate->set_preview( true );
328
		$this->_init_queue_and_generator();
329
		$this->queue_for_generation( $message_to_generate, $test_send );
330
		$generated_queue = $this->_generator->generate( false );
331
		if ( $generated_queue->execute( false ) ) {
332
			//the first queue item should be the preview
333
			$generated_queue->get_message_repository()->rewind();
334
			if ( ! $generated_queue->get_message_repository()->valid() ) {
335
				return $generated_queue;
336
			}
337
			return $generated_queue->get_message_repository()->is_test_send() ? true : $generated_queue;
0 ignored issues
show
Bug Compatibility introduced by
The expression $generated_queue->get_me...rue : $generated_queue; of type boolean|EE_Messages_Queue adds the type boolean to the return on line 337 which is incompatible with the return type documented by EE_Messages_Processor::generate_for_preview of type EE_Messages_Queue.
Loading history...
338
		} else {
339
			return false;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return false; (false) is incompatible with the return type documented by EE_Messages_Processor::generate_for_preview of type EE_Messages_Queue.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
340
		}
341
	}
342
343
344
	/**
345
	 * This queues for sending.
346
	 * The messenger send now method is also verified to see if sending immediately is requested.
347
	 * otherwise its just saved to the queue.
348
	 * @param EE_Message_To_Generate $message_to_generate
349
	 * @return bool true or false for success.
350
	 */
351
	public function queue_for_sending( EE_Message_To_Generate $message_to_generate ) {
352
		if ( ! $message_to_generate->valid() ) {
353
			return false;
354
		}
355
		$this->_init_queue_and_generator();
356
		$message = $message_to_generate->get_EE_Message();
357
		$this->_queue->add( $message );
358
		if ( $message->send_now() ) {
359
			$this->_queue->execute( false );
360
		} else {
361
			$this->_queue->save();
362
		}
363
		return true;
364
	}
365
366
367
	/**
368
	 * This generates and sends from the given EE_Message_To_Generate class immediately.
369
	 * @param EE_Message_To_Generate $message_to_generate
370
	 * @return EE_Messages_Queue | null
371
	 */
372
	public function generate_and_send_now( EE_Message_To_Generate $message_to_generate ) {
373
		if ( ! $message_to_generate->valid() ) {
374
			return null;
375
		}
376
		// is there supposed to be a sending messenger for this message?
377
		if ( $message_to_generate instanceof EEI_Has_Sending_Messenger ) {
378
			// make sure it's valid, but if it's not,
379
			// then set the value of $sending_messenger to an EE_Error object
380
			// so that downstream code can easily see that things went wrong.
381
			$sending_messenger = $message_to_generate->sending_messenger() instanceof EE_messenger
382
				? $message_to_generate->sending_messenger()
383
				: new EE_Error(
384
					__(
385
						'There was a specific sending messenger requested for the send action, but it was either invalid or not active at time of sending.',
386
						'event_espresso'
387
					)
388
				);
389
		} else {
390
			$sending_messenger = null;
391
		}
392
393
		if ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle ) {
394
			$this->_init_queue_and_generator();
395
			$this->_queue->add( $message_to_generate->get_EE_Message() );
396
			$this->_queue->execute( false, $sending_messenger );
397
			return $this->_queue;
398
		} elseif ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete ) {
399
			$generated_queue = $this->generate_and_return( array( $message_to_generate ) );
400
			$generated_queue->execute( false, $sending_messenger );
401
			return $generated_queue;
402
		}
403
		return null;
404
	}
405
406
407
408
409
	/**
410
	 * Creates mtg objects for all active messengers and queues for generation.
411
	 * This method also calls the execute by priority method on the queue which will optionally kick off a new non-blocking
412
	 * request to complete the action if the priority for the message requires immediate action.
413
	 * @param string $message_type
414
	 * @param mixed  $data   The data being used for generation.
415
	 * @param bool   $persist   Whether to persist the queued messages to the db or not.
416
	 */
417
	public function generate_for_all_active_messengers( $message_type, $data, $persist = true ) {
418
		$messages_to_generate = $this->setup_mtgs_for_all_active_messengers( $message_type, $data );
419
		if ( $persist ) {
420
			$this->batch_queue_for_generation_and_persist( $messages_to_generate );
421
			$this->_queue->initiate_request_by_priority();
422
		} else {
423
			$this->batch_queue_for_generation_no_persist( $messages_to_generate );
424
		}
425
	}
426
427
428
429
430
	/**
431
	 * This simply loops through all active messengers and takes care of setting up the
432
	 * EE_Message_To_Generate objects.
433
	 * @param $message_type
434
	 * @param $data
435
	 *
436
	 * @return EE_Message_To_Generate[]
437
	 */
438
	public function setup_mtgs_for_all_active_messengers( $message_type, $data ) {
439
		$messages_to_generate = array();
440
		foreach ( $this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object  ) {
441
			$message_to_generate = new EE_Message_To_Generate( $messenger_slug, $message_type, $data );
442
			if ( $message_to_generate->valid() ) {
443
				$messages_to_generate[] = $message_to_generate;
444
			}
445
		}
446
		return $messages_to_generate;
447
	}
448
449
450
451
452
	/**
453
	 * This accepts an array of EE_Message::MSG_ID values and will use that to retrieve the objects from the database
454
	 * and send.
455
	 * @param array $message_ids
456
	 */
457
	public function setup_messages_from_ids_and_send( $message_ids ) {
458
		$this->_init_queue_and_generator();
459
		$messages = EEM_Message::instance()->get_all( array(
460
			array(
461
				'MSG_ID' => array( 'IN', $message_ids ),
462
				'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_sent() )
463
			)
464
		));
465
		//set the Messages to resend.
466
		foreach ( $messages as $message ) {
467
			if ( $message instanceof EE_Message ) {
468
				$message->set_STS_ID( EEM_Message::status_resend );
469
				$this->_queue->add( $message );
470
			}
471
		}
472
473
		$this->_queue->initiate_request_by_priority( 'send' );
474
	}
475
476
477
478
	/**
479
	 * This method checks for registration IDs in the request via the given key and creates the messages to generate
480
	 * objects from them, then returns the array of messages to generate objects.
481
	 * Note, this sets up registrations for the registration family of message types.
482
	 *
483
	 * @param string $registration_ids_key  This is used to indicate what represents the registration ids in the request.
484
	 *
485
	 * @return EE_Message_To_Generate[]
486
	 */
487
	public function setup_messages_to_generate_from_registration_ids_in_request( $registration_ids_key = '_REG_ID' ) {
488
		EE_Registry::instance()->load_core( 'Request_Handler' );
489
		EE_Registry::instance()->load_helper( 'MSG_Template' );
490
		$regs_to_send = array();
491
		$regIDs = EE_Registry::instance()->REQ->get( $registration_ids_key );
492
		if ( empty( $regIDs ) ) {
493
			EE_Error::add_error( __('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
494
			return false;
495
		}
496
497
		//make sure is an array
498
		$regIDs = is_array( $regIDs ) ? $regIDs : array( $regIDs );
499
500
		foreach( $regIDs as $regID ) {
501
			$reg = EEM_Registration::instance()->get_one_by_ID( $regID );
502 View Code Duplication
			if ( ! $reg instanceof EE_Registration ) {
503
				EE_Error::add_error( sprintf( __('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID ) );
504
				return false;
505
			}
506
			$regs_to_send[$reg->transaction_ID()][$reg->status_ID()][] = $reg;
507
		}
508
509
		$messages_to_generate = array();
510
511
		foreach ( $regs_to_send as $status_group ) {
512
			foreach ( $status_group as $status_id => $registrations ) {
513
				$messages_to_generate = $messages_to_generate + $this->setup_mtgs_for_all_active_messengers(
514
						EEH_MSG_Template::convert_reg_status_to_message_type( $status_id ),
515
						array( $registrations, $status_id )
516
					);
517
			}
518
		}
519
520
		return $messages_to_generate;
521
	}
522
523
524
525
} //end class EE_Messages_Processor