3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
21 namespace MediaWiki\Mail
;
23 use MediaWiki\Config\Config
;
24 use MediaWiki\Config\ServiceOptions
;
25 use MediaWiki\HookContainer\HookContainer
;
26 use MediaWiki\Permissions\Authority
;
27 use MediaWiki\User\CentralId\CentralIdLookup
;
28 use MediaWiki\User\Options\UserOptionsLookup
;
29 use MediaWiki\User\UserFactory
;
30 use Wikimedia\Message\IMessageFormatterFactory
;
31 use Wikimedia\Message\ITextFormatter
;
34 * Factory for EmailUser objects.
36 * Obtain via ServiceWiring.
41 class EmailUserFactory
{
42 private ServiceOptions
$options;
43 private HookContainer
$hookContainer;
44 private UserOptionsLookup
$userOptionsLookup;
45 private CentralIdLookup
$centralIdLookup;
46 private UserFactory
$userFactory;
47 private IEmailer
$emailer;
48 private IMessageFormatterFactory
$messageFormatterFactory;
49 private ITextFormatter
$contLangMsgFormatter;
52 * @internal For use by ServiceWiring only.
54 * @param ServiceOptions $options
55 * @param HookContainer $hookContainer
56 * @param UserOptionsLookup $userOptionsLookup
57 * @param CentralIdLookup $centralIdLookup
58 * @param UserFactory $userFactory
59 * @param IEmailer $emailer
60 * @param IMessageFormatterFactory $messageFormatterFactory
61 * @param ITextFormatter $contLangMsgFormatter
63 public function __construct(
64 ServiceOptions
$options,
65 HookContainer
$hookContainer,
66 UserOptionsLookup
$userOptionsLookup,
67 CentralIdLookup
$centralIdLookup,
68 UserFactory
$userFactory,
70 IMessageFormatterFactory
$messageFormatterFactory,
71 ITextFormatter
$contLangMsgFormatter
73 $options->assertRequiredOptions( EmailUser
::CONSTRUCTOR_OPTIONS
);
74 $this->options
= $options;
75 $this->hookContainer
= $hookContainer;
76 $this->userOptionsLookup
= $userOptionsLookup;
77 $this->centralIdLookup
= $centralIdLookup;
78 $this->userFactory
= $userFactory;
79 $this->emailer
= $emailer;
80 $this->messageFormatterFactory
= $messageFormatterFactory;
81 $this->contLangMsgFormatter
= $contLangMsgFormatter;
85 * @param Authority $sender
88 public function newEmailUser( Authority
$sender ): EmailUser
{
92 $this->userOptionsLookup
,
93 $this->centralIdLookup
,
96 $this->messageFormatterFactory
,
97 $this->contLangMsgFormatter
,
103 * @internal Temporary BC method for SpecialEmailUser
104 * @param Authority $sender
105 * @param Config|null $config
108 public function newEmailUserBC( Authority
$sender, ?Config
$config = null ): EmailUser
{
109 $options = $config ?
new ServiceOptions( EmailUser
::CONSTRUCTOR_OPTIONS
, $config ) : $this->options
;
110 return new EmailUser(
112 $this->hookContainer
,
113 $this->userOptionsLookup
,
114 $this->centralIdLookup
,
117 $this->messageFormatterFactory
,
118 $this->contLangMsgFormatter
,