Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / auth / AbstractAuthenticationProvider.php
blob732985fe7c2306c97e1ab4afa474f7436c035871
1 <?php
2 /**
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
18 * @file
19 * @ingroup Auth
22 namespace MediaWiki\Auth;
24 use MediaWiki\Config\Config;
25 use MediaWiki\HookContainer\HookContainer;
26 use MediaWiki\HookContainer\HookRunner;
27 use MediaWiki\User\UserNameUtils;
28 use Psr\Log\LoggerInterface;
30 /**
31 * A base class that implements some of the boilerplate for an AuthenticationProvider
32 * @stable to extend
33 * @ingroup Auth
34 * @since 1.27
36 abstract class AbstractAuthenticationProvider implements AuthenticationProvider {
37 protected LoggerInterface $logger;
38 protected AuthManager $manager;
39 protected Config $config;
40 private HookContainer $hookContainer;
41 private HookRunner $hookRunner;
42 protected UserNameUtils $userNameUtils;
44 /**
45 * Initialise with dependencies of an AuthenticationProvider
47 * @since 1.37
48 * @internal In production code AuthManager will initialize the
49 * AbstractAuthenticationProvider, in tests
50 * AuthenticationProviderTestTrait must be used.
52 public function init(
53 LoggerInterface $logger,
54 AuthManager $manager,
55 HookContainer $hookContainer,
56 Config $config,
57 UserNameUtils $userNameUtils
58 ) {
59 $this->logger = $logger;
60 $this->manager = $manager;
61 $this->hookContainer = $hookContainer;
62 $this->hookRunner = new HookRunner( $hookContainer );
63 $this->config = $config;
64 $this->userNameUtils = $userNameUtils;
65 $this->postInitSetup();
68 /**
69 * A provider can override this to do any necessary setup after init()
70 * is called.
72 * @since 1.37
73 * @stable to override
75 protected function postInitSetup() {
78 /**
79 * @inheritDoc
80 * @note Override this if it makes sense to support more than one instance
82 public function getUniqueId() {
83 return static::class;
86 /**
87 * @since 1.35
88 * @return HookContainer
90 protected function getHookContainer(): HookContainer {
91 return $this->hookContainer;
94 /**
95 * @internal This is for use by core only. Hook interfaces may be removed
96 * without notice.
97 * @since 1.35
98 * @return HookRunner
100 protected function getHookRunner(): HookRunner {
101 return $this->hookRunner;