/** * Activates the specified messenger. * * @param string $messenger_name * @param array $message_type_names An array of message type names to activate with this messenger. * If included we do NOT setup the default message types * (assuming they are already setup.) * @param bool $update_active_messengers_option * * @return array of generated templates * @throws \EE_Error */ public function activate_messenger($messenger_name, $message_type_names = array(), $update_active_messengers_option = true) { $templates = array(); // grab the messenger to work with. $messenger = $this->messenger_collection()->get_by_info($messenger_name); // it's inactive. Activate it. if ($messenger instanceof EE_messenger) { $this->_active_messengers[$messenger->name] = $messenger; //activate incoming message types set to be activated with messenger. $message_type_names = $this->_activate_message_types($messenger, $message_type_names); // setup any initial settings for the messenger if necessary. $this->add_settings_for_messenger($messenger->name); if ($update_active_messengers_option) { $this->update_active_messengers_option(); $this->update_has_activated_messengers_option(); } //generate new templates if necessary and ensure all related templates that are already in the database are //marked active. Note, this will also deactivate a message type for a messenger if the template //cannot be successfully created during its attempt (only happens for global template attempts). if (!empty($message_type_names)) { $templates = EEH_MSG_Template::generate_new_templates($messenger->name, $message_type_names, 0, true); EEH_MSG_Template::update_to_active(array($messenger->name), $message_type_names); } } return $templates; }