/** * Returns sendername from a couple of arguments * * @param Mail $mail Given Params * @param string|array $default String as default or cObject array * @param string $glue * @return string Sender Name */ public function getSenderNameFromArguments(Mail $mail, $default = null, $glue = ' ') { $name = ''; foreach ($mail->getAnswers() as $answer) { /** @var Answer $answer */ if (method_exists($answer->getField(), 'getUid') && $answer->getField()->isSenderName()) { if (!is_array($answer->getValue())) { $value = $answer->getValue(); } else { $value = implode($glue, $answer->getValue()); } $name .= $value . $glue; } } if (!trim($name) && $default) { if (!is_array($default)) { $name = $default; } else { /** @var ContentObjectRenderer $contentObject */ $contentObject = GeneralUtility::makeInstance(ObjectManager::class)->get(ContentObjectRenderer::class); $name = $contentObject->cObjGetSingle($default[0][$default[1]], $default[0][$default[1] . '.']); } } if (empty($name) && !empty(ConfigurationUtility::getDefaultMailFromName())) { $name = ConfigurationUtility::getDefaultMailFromName(); } if (!trim($name)) { $name = LocalizationUtility::translate('error_no_sender_name'); } return trim($name); }