/** * This simply loops through all active messengers and takes care of setting up the * EE_Message_To_Generate objects. * @param $message_type * @param $data * * @return EE_Message_To_Generate[] */ public function setup_mtgs_for_all_active_messengers($message_type, $data) { $messages_to_generate = array(); foreach ($this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object) { $message_to_generate = new EE_Message_To_Generate($messenger_slug, $message_type, $data); if ($message_to_generate->valid()) { $messages_to_generate[] = $message_to_generate; } } return $messages_to_generate; }
/** * The queued EE_Message for generation does not save the data used for generation as objects * because serialization of those objects could be problematic if the data is saved to the db. * So this method calls the static method on the associated data_handler for the given message_type * and that preps the data for later instantiation when generating. * * @param EE_Message_To_Generate $message_to_generate * @param bool $preview Indicate whether this is being used for a preview or not. * @return mixed Prepped data for persisting to the queue. false is returned if unable to prep data. */ protected function _prepare_data_for_queue(EE_Message_To_Generate $message_to_generate, $preview) { /** @type EE_Messages_incoming_data $data_handler - well not really... just the class name actually */ $data_handler = $message_to_generate->get_data_handler_class_name($preview); if (!$message_to_generate->valid()) { return false; //unable to get the data because the info in the EE_Message_To_Generate class is invalid. } return $data_handler::convert_data_for_persistent_storage($message_to_generate->data()); }