mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-11 17:44:27 +02:00
simplify mail creation
This commit is contained in:
parent
9f95b975b4
commit
0b94b84dc7
8 changed files with 32 additions and 25 deletions
|
@ -86,13 +86,18 @@ abstract class MailBuilder
|
|||
/**
|
||||
* Adds the User ID to the email in case the mail sending needs additional properties of this user
|
||||
*
|
||||
* @param int $uid The User ID
|
||||
* @todo Once the user array is replaced with a user entity, replace this array parameter as well
|
||||
* @param array $user The user entity/array, for which the email should be sent
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function forUser(int $uid)
|
||||
public function forUser(array $user)
|
||||
{
|
||||
$this->recipientUid = $uid;
|
||||
$this->recipientUid = $user['uid'] ?? 0;
|
||||
try {
|
||||
$this->l10n = $user['language'] ? $this->l10n->withLang($user['language']) : $this->l10n;
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -28,18 +28,22 @@ class Emailer
|
|||
private $logger;
|
||||
/** @var App\BaseURL */
|
||||
private $baseUrl;
|
||||
/** @var L10n */
|
||||
private $l10n;
|
||||
|
||||
/** @var string */
|
||||
private $siteEmailAddress;
|
||||
/** @var string */
|
||||
private $siteEmailName;
|
||||
|
||||
public function __construct(IConfig $config, IPConfig $pConfig, App\BaseURL $baseURL, LoggerInterface $logger)
|
||||
public function __construct(IConfig $config, IPConfig $pConfig, App\BaseURL $baseURL, LoggerInterface $logger,
|
||||
L10n $defaultLang)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->pConfig = $pConfig;
|
||||
$this->logger = $logger;
|
||||
$this->baseUrl = $baseURL;
|
||||
$this->l10n = $defaultLang;
|
||||
|
||||
$this->siteEmailAddress = $this->config->get('config', 'sender_email');
|
||||
if (empty($sysEmailAddress)) {
|
||||
|
@ -77,13 +81,11 @@ class Emailer
|
|||
/**
|
||||
* Creates a new system email
|
||||
*
|
||||
* @param L10n $l10n The chosen language for the new email
|
||||
*
|
||||
* @return SystemMailBuilder
|
||||
*/
|
||||
public function newSystemMail(L10n $l10n)
|
||||
public function newSystemMail()
|
||||
{
|
||||
return new SystemMailBuilder($l10n, $this->baseUrl, $this->config,
|
||||
return new SystemMailBuilder($this->l10n, $this->baseUrl, $this->config,
|
||||
$this->getSiteEmailAddress(), $this->getSiteEmailName());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue