private function buildAdminMailConfigurationByDynamic(Dynamic $dynamic)
    {
        $form = $dynamic->getForm();
        $locale = $dynamic->getLocale();
        $translation = $form->getTranslation($locale);

        if ($translation->getDeactivateNotifyMails()) {
            return null;
        }

        $adminMailConfiguration = $this->createMailConfiguration($locale);

        $adminMailConfiguration->setSubject($translation->getSubject());
        $adminMailConfiguration->setFrom(
            $this->getEmail($translation->getFromEmail(), $translation->getFromName())
        );

        // Set Receivers for the email.
        $toList = $this->getEmail($translation->getToEmail(), $translation->getToName()) ?: [];
        $ccList = [];
        $bccList = [];

        foreach ($translation->getReceivers() as $receiver) {
            $email = $this->getEmail($receiver->getEmail(), $receiver->getName());

            if (MailConfigurationInterface::TYPE_TO == $receiver->getType()) {
                $toList = array_merge($toList, $email);
            } elseif (MailConfigurationInterface::TYPE_CC == $receiver->getType()) {
                $ccList = array_merge($ccList, $email);
            } elseif (MailConfigurationInterface::TYPE_BCC == $receiver->getType()) {
                $bccList = array_merge($bccList, $email);
            }
        }

        $adminMailConfiguration->setTo(array_filter($toList));
        $adminMailConfiguration->setCc(array_filter($ccList));
        $adminMailConfiguration->setBcc(array_filter($bccList));

        if ($translation->getReplyTo()) {
            $adminMailConfiguration->setReplyTo($this->getEmailFromDynamic($dynamic));
        }

        // Set attachment configuration.
        $adminMailConfiguration->setAddAttachments($translation->getSendAttachments());

        // Set template.
        $adminMailConfiguration->setTemplate($this->mailAdminTemplate);
        $adminMailConfiguration->setTemplateAttributes($this->getTemplateAttributesFromDynamic($dynamic));

        return $adminMailConfiguration;
    }
private function buildAdminMailConfigurationByDynamic(Dynamic $dynamic)
    {
        $form = $dynamic->getForm();
        $locale = $dynamic->getLocale();
        $translation = $form->getTranslation($locale);

        if ($translation->getDeactivateNotifyMails()) {
            return null;
        }

        $adminMailConfiguration = $this->createMailConfiguration($locale);

        $adminMailConfiguration->setSubject($translation->getSubject());
        $adminMailConfiguration->setFrom(
            $this->getEmail($translation->getFromEmail(), $translation->getFromName())
        );

        // Set Receivers for the email.
        $toList = $this->getEmail($translation->getToEmail(), $translation->getToName()) ?: [];
        $ccList = [];
        $bccList = [];

        foreach ($translation->getReceivers() as $receiver) {
            $email = $this->getEmail($receiver->getEmail(), $receiver->getName());

            if (MailConfigurationInterface::TYPE_TO == $receiver->getType()) {
                $toList = array_merge($toList, $email);
            } elseif (MailConfigurationInterface::TYPE_CC == $receiver->getType()) {
                $ccList = array_merge($ccList, $email);
            } elseif (MailConfigurationInterface::TYPE_BCC == $receiver->getType()) {
                $bccList = array_merge($bccList, $email);
            }
        }

        $adminMailConfiguration->setTo(array_filter($toList));
        $adminMailConfiguration->setCc(array_filter($ccList));
        $adminMailConfiguration->setBcc(array_filter($bccList));

        if ($translation->getReplyTo()) {
            $adminMailConfiguration->setReplyTo($this->getEmailFromDynamic($dynamic));
        }

        // Set attachment configuration.
        $adminMailConfiguration->setAddAttachments($translation->getSendAttachments());

        // Set template.
        $adminMailConfiguration->setTemplate($this->mailAdminTemplate);
        $adminMailConfiguration->setTemplateAttributes($this->getTemplateAttributesFromDynamic($dynamic));

        return $adminMailConfiguration;
    }
private function buildAdminMailConfigurationByDynamic ( Dynamic $ dynamic ) { $ form = $ dynamic -> getForm ( ) ; $ locale = $ dynamic -> getLocale ( ) ; $ translation = $ form -> getTranslation ( $ locale ) ; if ( $ translation -> getDeactivateNotifyMails ( ) ) { return null ; } $ adminMailConfiguration = $ this -> createMailConfiguration ( $ locale ) ; $ adminMailConfiguration -> setSubject ( $ translation -> getSubject ( ) ) ; $ adminMailConfiguration -> setFrom ( $ this -> getEmail ( $ translation -> getFromEmail ( ) , $ translation -> getFromName ( ) ) ) ; // Set Receivers for the email. $ toList = $ this -> getEmail ( $ translation -> getToEmail ( ) , $ translation -> getToName ( ) ) ? : [ ] ; $ ccList = [ ] ; $ bccList = [ ] ; foreach ( $ translation -> getReceivers ( ) as $ receiver ) { $ email = $ this -> getEmail ( $ receiver -> getEmail ( ) , $ receiver -> getName ( ) ) ; if ( MailConfigurationInterface :: TYPE_TO == $ receiver -> getType ( ) ) { $ toList = array_merge ( $ toList , $ email ) ; } elseif ( MailConfigurationInterface :: TYPE_CC == $ receiver -> getType ( ) ) { $ ccList = array_merge ( $ ccList , $ email ) ; } elseif ( MailConfigurationInterface :: TYPE_BCC == $ receiver -> getType ( ) ) { $ bccList = array_merge ( $ bccList , $ email ) ; } } $ adminMailConfiguration -> setTo ( array_filter ( $ toList ) ) ; $ adminMailConfiguration -> setCc ( array_filter ( $ ccList ) ) ; $ adminMailConfiguration -> setBcc ( array_filter ( $ bccList ) ) ; if ( $ translation -> getReplyTo ( ) ) { $ adminMailConfiguration -> setReplyTo ( $ this -> getEmailFromDynamic ( $ dynamic ) ) ; } // Set attachment configuration. $ adminMailConfiguration -> setAddAttachments ( $ translation -> getSendAttachments ( ) ) ; // Set template. $ adminMailConfiguration -> setTemplate ( $ this -> mailAdminTemplate ) ; $ adminMailConfiguration -> setTemplateAttributes ( $ this -> getTemplateAttributesFromDynamic ( $ dynamic ) ) ; return $ adminMailConfiguration ; }
Build admin mail configuration by dynamic entity.

@param Dynamic $dynamic

@return MailConfiguration|null
Build admin mail configuration by dynamic entity .