1<?php
2
3/**
4 * Service Wirings for Vector skin
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * @file
22 * @since 1.35
23 */
24
25use MediaWiki\MediaWikiServices;
26use Vector\Constants;
27use Vector\FeatureManagement\FeatureManager;
28use Vector\FeatureManagement\Requirements\DynamicConfigRequirement;
29use Vector\FeatureManagement\Requirements\LatestSkinVersionRequirement;
30use Vector\SkinVersionLookup;
31
32return [
33	Constants::SERVICE_CONFIG => function ( MediaWikiServices $services ) {
34		return $services->getService( 'ConfigFactory' )->makeConfig( Constants::SKIN_NAME );
35	},
36	Constants::SERVICE_FEATURE_MANAGER => function ( MediaWikiServices $services ) {
37		$featureManager = new FeatureManager();
38
39		$featureManager->registerRequirement(
40			new DynamicConfigRequirement(
41				$services->getMainConfig(),
42				Constants::CONFIG_KEY_FULLY_INITIALISED,
43				Constants::REQUIREMENT_FULLY_INITIALISED
44			)
45		);
46
47		// Feature: Latest skin
48		// ====================
49		$context = RequestContext::getMain();
50
51		$featureManager->registerRequirement(
52			new LatestSkinVersionRequirement(
53				new SkinVersionLookup(
54					$context->getRequest(),
55					$context->getUser(),
56					$services->getService( Constants::SERVICE_CONFIG )
57				)
58			)
59		);
60
61		$featureManager->registerFeature(
62			Constants::FEATURE_LATEST_SKIN,
63			[
64				Constants::REQUIREMENT_FULLY_INITIALISED,
65				Constants::REQUIREMENT_LATEST_SKIN_VERSION,
66			]
67		);
68
69		return $featureManager;
70	}
71];
72