private function prepareMessageUsingTemplate(
        CNabuMessagingTemplate $nb_template,
        CNabuLanguage $nb_language,
        array $params = null
    ) : array
    {
        $nb_engine = CNabuEngine::getEngine();

        if (is_string($interface_name = $nb_template->getRenderInterface()) &&
            is_string($provider_key = $nb_template->getRenderProvider()) &&
            count(list($vendor_key, $module_key) = preg_split("/:/", $provider_key)) === 2 &&
            ($nb_manager = $nb_engine->getProviderManager($vendor_key, $module_key)) instanceof INabuMessagingModule &&
            ($nb_interface = $nb_manager->createTemplateRenderInterface($interface_name)) instanceof INabuMessagingTemplateRenderInterface
        ) {
            $nb_interface->setTemplate($nb_template);
            $nb_interface->setLanguage($nb_language);
            $subject = $nb_interface->createSubject($params);
            $body_html = $nb_interface->createBodyHTML($params);
            $body_text = $nb_interface->createBodyText($params);

            return array($subject, $body_html, $body_text);
        } else {
            throw new ENabuMessagingException(ENabuMessagingException::ERROR_INVALID_TEMPLATE_RENDER_INSTANCE);
        }
    }
private function prepareMessageUsingTemplate(
        CNabuMessagingTemplate $nb_template,
        CNabuLanguage $nb_language,
        array $params = null
    ) : array
    {
        $nb_engine = CNabuEngine::getEngine();

        if (is_string($interface_name = $nb_template->getRenderInterface()) &&
            is_string($provider_key = $nb_template->getRenderProvider()) &&
            count(list($vendor_key, $module_key) = preg_split("/:/", $provider_key)) === 2 &&
            ($nb_manager = $nb_engine->getProviderManager($vendor_key, $module_key)) instanceof INabuMessagingModule &&
            ($nb_interface = $nb_manager->createTemplateRenderInterface($interface_name)) instanceof INabuMessagingTemplateRenderInterface
        ) {
            $nb_interface->setTemplate($nb_template);
            $nb_interface->setLanguage($nb_language);
            $subject = $nb_interface->createSubject($params);
            $body_html = $nb_interface->createBodyHTML($params);
            $body_text = $nb_interface->createBodyText($params);

            return array($subject, $body_html, $body_text);
        } else {
            throw new ENabuMessagingException(ENabuMessagingException::ERROR_INVALID_TEMPLATE_RENDER_INSTANCE);
        }
    }
private function prepareMessageUsingTemplate ( CNabuMessagingTemplate $ nb_template , CNabuLanguage $ nb_language , array $ params = null ) : array { $ nb_engine = CNabuEngine :: getEngine ( ) ; if ( is_string ( $ interface_name = $ nb_template -> getRenderInterface ( ) ) && is_string ( $ provider_key = $ nb_template -> getRenderProvider ( ) ) && count ( list ( $ vendor_key , $ module_key ) = preg_split ( "/:/" , $ provider_key ) ) === 2 && ( $ nb_manager = $ nb_engine -> getProviderManager ( $ vendor_key , $ module_key ) ) instanceof INabuMessagingModule && ( $ nb_interface = $ nb_manager -> createTemplateRenderInterface ( $ interface_name ) ) instanceof INabuMessagingTemplateRenderInterface ) { $ nb_interface -> setTemplate ( $ nb_template ) ; $ nb_interface -> setLanguage ( $ nb_language ) ; $ subject = $ nb_interface -> createSubject ( $ params ) ; $ body_html = $ nb_interface -> createBodyHTML ( $ params ) ; $ body_text = $ nb_interface -> createBodyText ( $ params ) ; return array ( $ subject , $ body_html , $ body_text ) ; } else { throw new ENabuMessagingException ( ENabuMessagingException :: ERROR_INVALID_TEMPLATE_RENDER_INSTANCE ) ; } }
Prepares the subject and body of a message using a template.
@param CNabuMessagingTemplate $nb_template The Template instance to be used to render the message.
@param CNabuLanguage $nb_language The Language instance to get valid fields.
@param array|null $params An associative array with additional data for the template.
@return array Retuns an array of three cells, where the first is the subject, the second is the body in HTML
and the third the body as text.
@throws ENabuMessagingException Raises an exception if the designated template is not valid or applicable.
Prepares the subject and body of a message using a template .