21 if ( $this->definition ===
null ) {
29 $module = $this->definition[
'themeImages'] ??
'';
32 foreach ( $themes as $skin => $theme ) {
41 foreach ( $data as $key => $value ) {
54 throw new LogicException(
55 "Mismatched OOUI theme images definition: " .
56 "key '$key' of theme '$theme' for module '$module' " .
57 "does not match other themes"
66 if ( str_starts_with( $module,
'icons' ) ) {
67 $definition[
'selectorWithoutVariant'] =
'.oo-ui-icon-{name}, .mw-ui-icon-{name}:before';
68 $definition[
'selectorWithVariant'] =
'.oo-ui-image-{variant}.oo-ui-icon-{name}, ' .
69 '.mw-ui-icon-{name}-{variant}:before';
75 parent::loadFromDefinition();
94 $this->definition[
'rootPath'] .
'/' .
95 strtolower( $theme ) .
'/' .
96 $this->definition[
'name'] .
'.json';
112 if ( !file_exists( $localDataPath ) ) {
116 $data = json_decode( file_get_contents( $localDataPath ),
true );
120 $fixPath =
static function ( &
$path ) use ( $dataPath ) {
121 if ( $dataPath instanceof
FilePath ) {
123 dirname( $dataPath->getPath() ) .
'/' .
$path,
124 $dataPath->getLocalBasePath(),
125 $dataPath->getRemoteBasePath()
132 array_walk( $data[
'images'],
static function ( &$value ) use ( $fixPath ) {
133 if ( is_string( $value[
'file'] ) ) {
134 $fixPath( $value[
'file'] );
135 } elseif ( is_array( $value[
'file'] ) ) {
136 array_walk_recursive( $value[
'file'], $fixPath );
trait OOUIModule
Convenience methods for dealing with OOUI themes and their relations to MW skins.