MediaWiki REL1_32
ResourceLoaderOOUIModule.php
Go to the documentation of this file.
1<?php
27 protected static $knownScriptsModules = [ 'core' ];
28 protected static $knownStylesModules = [ 'core', 'widgets', 'toolbars', 'windows' ];
29 protected static $knownImagesModules = [
30 'indicators', 'textures',
31 // Extra icons
32 'icons-accessibility',
33 'icons-alerts',
34 'icons-content',
35 'icons-editing-advanced',
36 'icons-editing-citation',
37 'icons-editing-core',
38 'icons-editing-list',
39 'icons-editing-styling',
40 'icons-interactions',
41 'icons-layout',
42 'icons-location',
43 'icons-media',
44 'icons-moderation',
45 'icons-movement',
46 'icons-user',
47 'icons-wikimedia',
48 ];
49
50 // Note that keys must be lowercase, values TitleCase.
51 protected static $builtinSkinThemeMap = [
52 'default' => 'WikimediaUI',
53 ];
54
55 // Note that keys must be TitleCase.
56 protected static $builtinThemePaths = [
57 'WikimediaUI' => [
58 'scripts' => 'resources/lib/ooui/oojs-ui-wikimediaui.js',
59 'styles' => 'resources/lib/ooui/oojs-ui-{module}-wikimediaui.css',
60 'images' => 'resources/lib/ooui/themes/wikimediaui/{module}.json',
61 ],
62 'Apex' => [
63 'scripts' => 'resources/lib/ooui/oojs-ui-apex.js',
64 'styles' => 'resources/lib/ooui/oojs-ui-{module}-apex.css',
65 'images' => 'resources/lib/ooui/themes/apex/{module}.json',
66 ],
67 ];
68
75 public static function getSkinThemeMap() {
77 $themeMap += ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' );
78 return $themeMap;
79 }
80
91 protected static function getThemePaths() {
92 $themePaths = self::$builtinThemePaths;
93 return $themePaths;
94 }
95
105 protected function getThemePath( $theme, $kind, $module ) {
106 $paths = self::getThemePaths();
107 $path = $paths[ $theme ][ $kind ];
108 $path = str_replace( '{module}', $module, $path );
109 return $path;
110 }
111
117 protected function getThemeScriptsPath( $theme, $module ) {
118 if ( !in_array( $module, self::$knownScriptsModules ) ) {
119 throw new InvalidArgumentException( "Invalid OOUI scripts module '$module'" );
120 }
121 return $this->getThemePath( $theme, 'scripts', $module );
122 }
123
129 protected function getThemeStylesPath( $theme, $module ) {
130 if ( !in_array( $module, self::$knownStylesModules ) ) {
131 throw new InvalidArgumentException( "Invalid OOUI styles module '$module'" );
132 }
133 return $this->getThemePath( $theme, 'styles', $module );
134 }
135
141 protected function getThemeImagesPath( $theme, $module ) {
142 if ( !in_array( $module, self::$knownImagesModules ) ) {
143 throw new InvalidArgumentException( "Invalid OOUI images module '$module'" );
144 }
145 return $this->getThemePath( $theme, 'images', $module );
146 }
147}
static $knownImagesModules
static getThemePaths()
Return a map of theme names to lists of paths from which a given theme should be loaded.
static $knownStylesModules
static $builtinSkinThemeMap
static $builtinThemePaths
getThemePath( $theme, $kind, $module)
Return a path to load given module of given theme from.
static getSkinThemeMap()
Return a map of skin names (in lowercase) to OOUI theme names, defining which theme a given skin shou...
trait ResourceLoaderOOUIModule
Convenience methods for dealing with OOUI themes and their relations to MW skins.
getThemeScriptsPath( $theme, $module)
getThemeStylesPath( $theme, $module)
getThemeImagesPath( $theme, $module)
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37