src/Helpers/Mailer.php
protected function getStatusSpecificBody(Result $invoiceSendResult)
    {
        $pluginSettings = $this->config->getPluginSettings();
        $isTestMode = $pluginSettings['debug'] === PluginConfig::Send_TestMode;
        $resultInvoice = $invoiceSendResult->getResponse();
        // @refactor: can be taken from invoice array if that would be part of the Result
        $isConcept = !$invoiceSendResult->hasError() && empty($resultInvoice['entryid']);
        $emailAsPdfSettings = $this->config->getEmailAsPdfSettings();
        $isEmailAsPdf = (bool) $emailAsPdfSettings['emailAsPdf'];

        // Collect the messages.
        $sentences = array();
        switch ($invoiceSendResult->getStatus()) {
            case Result::Status_Exception:
                $sentences[] = 'mail_body_exception';
                $sentences[] = $invoiceSendResult->isSent() ? 'mail_body_exception_invoice_maybe_created' : 'mail_body_exception_invoice_not_created';
                break;
            case Result::Status_Errors:
                $sentences[] = 'mail_body_errors';
                $sentences[] = 'mail_body_errors_not_created';
                if ($isEmailAsPdf) {
                    $sentences[] = 'mail_body_pdf_enabled';
                    $sentences[] = 'mail_body_pdf_not_sent_errors';
                }
                break;
            case Result::Status_Warnings:
                $sentences[] = 'mail_body_warnings';
                if ($isTestMode) {
                    $sentences[] = 'mail_body_testmode';
                } elseif ($isConcept) {
                    $sentences[] = 'mail_body_concept';
                    if ($isEmailAsPdf) {
                        $sentences[] = 'mail_body_pdf_enabled';
                        $sentences[] = 'mail_body_pdf_not_sent_concept';
                    }
                } else {
                    $sentences[] = 'mail_body_warnings_created';
                }
                break;
            case Result::Status_Success:
            default:
                $sentences[] = 'mail_body_success';
                if ($isTestMode) {
                    $sentences[] = 'mail_body_testmode';
                } elseif ($isConcept) {
                    $sentences[] = 'mail_body_concept';
                    if ($isEmailAsPdf) {
                        $sentences[] = 'mail_body_pdf_enabled';
                        $sentences[] = 'mail_body_pdf_not_sent_concept';
                    }
                }
                break;
        }

        // Translate the messages.
        foreach ($sentences as &$sentence) {
            $sentence = $this->t($sentence);
        }

        // Collapse and format the sentences.
        $sentences = implode(' ', $sentences);
        $texts = array(
            'text' => wordwrap($sentences, 70),
            'html' => "<p>$sentences</p>",
        );
        return $texts;
    }
protected function getStatusSpecificBody(Result $invoiceSendResult)
    {
        $pluginSettings = $this->config->getPluginSettings();
        $isTestMode = $pluginSettings['debug'] === PluginConfig::Send_TestMode;
        $resultInvoice = $invoiceSendResult->getResponse();
        // @refactor: can be taken from invoice array if that would be part of the Result
        $isConcept = !$invoiceSendResult->hasError() && empty($resultInvoice['entryid']);
        $emailAsPdfSettings = $this->config->getEmailAsPdfSettings();
        $isEmailAsPdf = (bool) $emailAsPdfSettings['emailAsPdf'];

        // Collect the messages.
        $sentences = array();
        switch ($invoiceSendResult->getStatus()) {
            case Result::Status_Exception:
                $sentences[] = 'mail_body_exception';
                $sentences[] = $invoiceSendResult->isSent() ? 'mail_body_exception_invoice_maybe_created' : 'mail_body_exception_invoice_not_created';
                break;
            case Result::Status_Errors:
                $sentences[] = 'mail_body_errors';
                $sentences[] = 'mail_body_errors_not_created';
                if ($isEmailAsPdf) {
                    $sentences[] = 'mail_body_pdf_enabled';
                    $sentences[] = 'mail_body_pdf_not_sent_errors';
                }
                break;
            case Result::Status_Warnings:
                $sentences[] = 'mail_body_warnings';
                if ($isTestMode) {
                    $sentences[] = 'mail_body_testmode';
                } elseif ($isConcept) {
                    $sentences[] = 'mail_body_concept';
                    if ($isEmailAsPdf) {
                        $sentences[] = 'mail_body_pdf_enabled';
                        $sentences[] = 'mail_body_pdf_not_sent_concept';
                    }
                } else {
                    $sentences[] = 'mail_body_warnings_created';
                }
                break;
            case Result::Status_Success:
            default:
                $sentences[] = 'mail_body_success';
                if ($isTestMode) {
                    $sentences[] = 'mail_body_testmode';
                } elseif ($isConcept) {
                    $sentences[] = 'mail_body_concept';
                    if ($isEmailAsPdf) {
                        $sentences[] = 'mail_body_pdf_enabled';
                        $sentences[] = 'mail_body_pdf_not_sent_concept';
                    }
                }
                break;
        }

        // Translate the messages.
        foreach ($sentences as &$sentence) {
            $sentence = $this->t($sentence);
        }

        // Collapse and format the sentences.
        $sentences = implode(' ', $sentences);
        $texts = array(
            'text' => wordwrap($sentences, 70),
            'html' => "<p>$sentences</p>",
        );
        return $texts;
    }
protected function getStatusSpecificBody ( Result $ invoiceSendResult ) { $ pluginSettings = $ this -> config -> getPluginSettings ( ) ; $ isTestMode = $ pluginSettings [ 'debug' ] === PluginConfig :: Send_TestMode ; $ resultInvoice = $ invoiceSendResult -> getResponse ( ) ; // @refactor: can be taken from invoice array if that would be part of the Result $ isConcept = ! $ invoiceSendResult -> hasError ( ) && empty ( $ resultInvoice [ 'entryid' ] ) ; $ emailAsPdfSettings = $ this -> config -> getEmailAsPdfSettings ( ) ; $ isEmailAsPdf = ( bool ) $ emailAsPdfSettings [ 'emailAsPdf' ] ; // Collect the messages. $ sentences = array ( ) ; switch ( $ invoiceSendResult -> getStatus ( ) ) { case Result :: Status_Exception : $ sentences [ ] = 'mail_body_exception' ; $ sentences [ ] = $ invoiceSendResult -> isSent ( ) ? 'mail_body_exception_invoice_maybe_created' : 'mail_body_exception_invoice_not_created' ; break ; case Result :: Status_Errors : $ sentences [ ] = 'mail_body_errors' ; $ sentences [ ] = 'mail_body_errors_not_created' ; if ( $ isEmailAsPdf ) { $ sentences [ ] = 'mail_body_pdf_enabled' ; $ sentences [ ] = 'mail_body_pdf_not_sent_errors' ; } break ; case Result :: Status_Warnings : $ sentences [ ] = 'mail_body_warnings' ; if ( $ isTestMode ) { $ sentences [ ] = 'mail_body_testmode' ; } elseif ( $ isConcept ) { $ sentences [ ] = 'mail_body_concept' ; if ( $ isEmailAsPdf ) { $ sentences [ ] = 'mail_body_pdf_enabled' ; $ sentences [ ] = 'mail_body_pdf_not_sent_concept' ; } } else { $ sentences [ ] = 'mail_body_warnings_created' ; } break ; case Result :: Status_Success : default : $ sentences [ ] = 'mail_body_success' ; if ( $ isTestMode ) { $ sentences [ ] = 'mail_body_testmode' ; } elseif ( $ isConcept ) { $ sentences [ ] = 'mail_body_concept' ; if ( $ isEmailAsPdf ) { $ sentences [ ] = 'mail_body_pdf_enabled' ; $ sentences [ ] = 'mail_body_pdf_not_sent_concept' ; } } break ; } // Translate the messages. foreach ( $ sentences as & $ sentence ) { $ sentence = $ this -> t ( $ sentence ) ; } // Collapse and format the sentences. $ sentences = implode ( ' ' , $ sentences ) ; $ texts = array ( 'text' => wordwrap ( $ sentences , 70 ) , 'html' => "<p>$sentences</p>" , ) ; return $ texts ; }
Returns the body for the mail.

The body depends on:
- the result status.
- the value of isSent (in the result object)
- whether the invoice was sent in test mode
- whether the invoice was sent as concept
- the emailAsPdf setting

@param \Siel\Acumulus\Invoice\Result $invoiceSendResult

@return string[]
Returns the body for the mail .