private function discoverTemplate($nb_template) : CNabuMessagingTemplate
    {
        if (!($nb_template instanceof CNabuMessagingTemplate)) {
            if (is_numeric($nb_template_id = nb_getMixedValue($nb_template, NABU_MESSAGING_TEMPLATE_FIELD_ID))) {
                $nb_template = $this->nb_messaging->getTemplate($nb_template_id);
            } elseif (is_string($nb_template_id)) {
                $nb_template = $this->nb_messaging->getTemplateByKey($nb_template_id);
            }
        }

        if (!($nb_template instanceof CNabuMessagingTemplate)) {
            throw new ENabuMessagingException(ENabuMessagingException::ERROR_INVALID_TEMPLATE);
        } elseif ($nb_template->getMessagingId() !== $this->nb_messaging->getId()) {
            throw new ENabuMessagingException(
                ENabuMessagingException::ERROR_TEMPLATE_NOT_ALLOWED,
                array($nb_template->getId())
            );
        }

        return $nb_template;
    }
private function discoverTemplate($nb_template) : CNabuMessagingTemplate
    {
        if (!($nb_template instanceof CNabuMessagingTemplate)) {
            if (is_numeric($nb_template_id = nb_getMixedValue($nb_template, NABU_MESSAGING_TEMPLATE_FIELD_ID))) {
                $nb_template = $this->nb_messaging->getTemplate($nb_template_id);
            } elseif (is_string($nb_template_id)) {
                $nb_template = $this->nb_messaging->getTemplateByKey($nb_template_id);
            }
        }

        if (!($nb_template instanceof CNabuMessagingTemplate)) {
            throw new ENabuMessagingException(ENabuMessagingException::ERROR_INVALID_TEMPLATE);
        } elseif ($nb_template->getMessagingId() !== $this->nb_messaging->getId()) {
            throw new ENabuMessagingException(
                ENabuMessagingException::ERROR_TEMPLATE_NOT_ALLOWED,
                array($nb_template->getId())
            );
        }

        return $nb_template;
    }
private function discoverTemplate ( $ nb_template ) : CNabuMessagingTemplate { if ( ! ( $ nb_template instanceof CNabuMessagingTemplate ) ) { if ( is_numeric ( $ nb_template_id = nb_getMixedValue ( $ nb_template , NABU_MESSAGING_TEMPLATE_FIELD_ID ) ) ) { $ nb_template = $ this -> nb_messaging -> getTemplate ( $ nb_template_id ) ; } elseif ( is_string ( $ nb_template_id ) ) { $ nb_template = $ this -> nb_messaging -> getTemplateByKey ( $ nb_template_id ) ; } } if ( ! ( $ nb_template instanceof CNabuMessagingTemplate ) ) { throw new ENabuMessagingException ( ENabuMessagingException :: ERROR_INVALID_TEMPLATE ) ; } elseif ( $ nb_template -> getMessagingId ( ) !== $ this -> nb_messaging -> getId ( ) ) { throw new ENabuMessagingException ( ENabuMessagingException :: ERROR_TEMPLATE_NOT_ALLOWED , array ( $ nb_template -> getId ( ) ) ) ; } return $ nb_template ; }
Discover the Messaging Template instance beside a lazzy reference to it.
@param mixed $nb_template A Template instance, a CNabuDataObject containing a field named
nb_messaging_template_id or a valid Id.
@return CNabuMessagingTemplate Returns the Messaging Template instance discovered.
@throws ENabuMessagingException Raises an exception if the reference is not valid.
Discover the Messaging Template instance beside a lazzy reference to it .