/** * Constructor * This instantiates the object using arguments from the given request and calling the parent constructor. * * @param EE_Message_Resource_Manager $message_resource_manager * @param EE_Request_Handler $request */ public function __construct(EE_Message_Resource_Manager $message_resource_manager, EE_Request_Handler $request) { parent::__construct($request->get('gen_msgr'), $request->get('message_type'), array(), $request->get('context')); if (!$this->valid()) { return; } $this->_sending_messenger = $message_resource_manager->get_active_messenger($request->get('snd_msgr')); $this->token = $request->get('token'); $this->_validate_request(); $this->_data = $this->_get_data_from_request($request->get('id')); }
/** * This returns the default messengers to generate templates for on activation of EE. * It considers: * - whether a messenger is already active in the db. * - whether a messenger has been made active at any time in the past. * * @static * @param EE_Message_Resource_Manager $message_resource_manager * @return EE_messenger[] */ protected static function _get_default_messengers_to_generate_on_activation(EE_Message_Resource_Manager $message_resource_manager) { $active_messengers = $message_resource_manager->active_messengers(); $installed_messengers = $message_resource_manager->installed_messengers(); $has_activated = $message_resource_manager->get_has_activated_messengers_option(); $messengers_to_generate = array(); foreach ($installed_messengers as $installed_messenger) { //if installed messenger is a messenger that should be activated on install //and is not already active //and has never been activated if (!$installed_messenger->activate_on_install || isset($active_messengers[$installed_messenger->name]) || isset($has_activated[$installed_messenger->name])) { continue; } $messengers_to_generate[$installed_messenger->name] = $installed_messenger; } return $messengers_to_generate; }
/** * @param string $sending_messenger_slug * @param \EE_Message_Resource_Manager $message_resource_manager * @return \EE_messenger | string */ protected function _set_sending_messenger($sending_messenger_slug, EE_Message_Resource_Manager $message_resource_manager) { $sending_messenger = $message_resource_manager->get_active_messenger($sending_messenger_slug); return $sending_messenger instanceof EE_messenger ? $sending_messenger : $sending_messenger_slug; }