1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 14:00:31 +02:00

[ticket/17135] Use email method instead of service collection where appropriate

PHPBB-17135
This commit is contained in:
rxu
2024-06-23 14:29:17 +07:00
parent 499464e1d3
commit 3fddff240c
9 changed files with 124 additions and 57 deletions

View File

@@ -18,9 +18,9 @@ use phpbb\console\command\command;
use phpbb\db\driver\driver_interface;
use phpbb\exception\runtime_exception;
use phpbb\language\language;
use phpbb\messenger\method\email;
use phpbb\passwords\manager;
use phpbb\user;
use phpbb\di\service_collection;
use Symfony\Component\Console\Command\Command as symfony_command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
@@ -40,12 +40,12 @@ class add extends command
/** @var config */
protected $config;
/** @var email */
protected $email_method;
/** @var language */
protected $language;
/** @var service_collection */
protected $messenger;
/** @var manager */
protected $password_manager;
@@ -75,12 +75,12 @@ class add extends command
* @param string $phpbb_root_path
* @param string $php_ext
*/
public function __construct(user $user, driver_interface $db, config $config, language $language, service_collection $messenger, manager $password_manager, $phpbb_root_path, $php_ext)
public function __construct(user $user, driver_interface $db, config $config, language $language, email $email_method, manager $password_manager, $phpbb_root_path, $php_ext)
{
$this->db = $db;
$this->config = $config;
$this->db = $db;
$this->email_method = $email_method;
$this->language = $language;
$this->messenger = $messenger;
$this->password_manager = $password_manager;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
@@ -313,18 +313,17 @@ class add extends command
$user_actkey = $this->get_activation_key($user_id);
$email_method = $this->messenger->offsetGet('messenger.method.email');
$email_method->set_use_queue(false);
$email_method->template($email_template, $this->user->lang_name);
$email_method->to($this->data['email'], $this->data['username']);
$email_method->anti_abuse_headers($this->config, $this->user);
$email_method->assign_vars([
$this->email_method->set_use_queue(false);
$this->email_method->template($email_template, $this->user->lang_name);
$this->email_method->to($this->data['email'], $this->data['username']);
$this->email_method->anti_abuse_headers($this->config, $this->user);
$this->email_method->assign_vars([
'WELCOME_MSG' => html_entity_decode($this->language->lang('WELCOME_SUBJECT', $this->config['sitename']), ENT_COMPAT),
'USERNAME' => html_entity_decode($this->data['username'], ENT_COMPAT),
'PASSWORD' => html_entity_decode($this->data['new_password'], ENT_COMPAT),
'U_ACTIVATE' => generate_board_url() . "/ucp.{$this->php_ext}?mode=activate&u=$user_id&k=$user_actkey",
]);
$email_method->send();
$this->email_method->send();
}
/**