Pimcore\Mail::setDocumentSettings PHP Method

setDocumentSettings() protected method

Sets the settings which are defined in the Document Settings (from,to,cc,bcc)
protected setDocumentSettings ( ) : Mail
return Mail Provides fluent interface
    protected function setDocumentSettings()
    {
        $document = $this->getDocument();
        if ($document instanceof Model\Document\Email) {
            if (!$this->recipientsCleared) {
                $to = $document->getToAsArray();
                if (!empty($to)) {
                    $this->addTo($to);
                }
                $cc = $document->getCcAsArray();
                if (!empty($cc)) {
                    $this->addCc($cc);
                }
                $bcc = $document->getBccAsArray();
                if (!empty($bcc)) {
                    $this->addBcc($bcc);
                }
            }
        }
        if ($document instanceof Model\Document\Email || $document instanceof Model\Document\Newsletter) {
            //if more than one "from" email address is defined -> we set the first one
            $fromArray = $document->getFromAsArray();
            if (!empty($fromArray)) {
                list($from) = $fromArray;
                if ($from) {
                    $this->clearFrom();
                    $fromAddress = $from;
                    $fromName = null;
                    if (preg_match("/(.*)<(.*)>/", $from, $matches)) {
                        $fromAddress = trim($matches[2]);
                        $fromName = trim($matches[1]);
                    }
                    $this->setFrom($fromAddress, $fromName);
                }
            }
        }
        return $this;
    }