35 if ( $this->definition ===
null ) {
43 $module = $this->definition[
'themeImages'] ??
'';
46 foreach ( $themes as $skin => $theme ) {
55 foreach ( $data as $key => $value ) {
68 throw new LogicException(
69 "Mismatched OOUI theme images definition: " .
70 "key '$key' of theme '$theme' for module '$module' " .
71 "does not match other themes"
80 if ( str_starts_with( $module,
'icons' ) ) {
81 $definition[
'selectorWithoutVariant'] =
'.oo-ui-icon-{name}, .mw-ui-icon-{name}:before';
82 $definition[
'selectorWithVariant'] =
'.oo-ui-image-{variant}.oo-ui-icon-{name}, ' .
83 '.mw-ui-icon-{name}-{variant}:before';
89 parent::loadFromDefinition();
108 $this->definition[
'rootPath'] .
'/' .
109 strtolower( $theme ) .
'/' .
110 $this->definition[
'name'] .
'.json';
126 if ( !file_exists( $localDataPath ) ) {
130 $data = json_decode( file_get_contents( $localDataPath ),
true );
134 $fixPath =
static function ( &
$path ) use ( $dataPath ) {
135 if ( $dataPath instanceof
FilePath ) {
137 dirname( $dataPath->getPath() ) .
'/' .
$path,
138 $dataPath->getLocalBasePath(),
139 $dataPath->getRemoteBasePath()
146 array_walk( $data[
'images'],
static function ( &$value ) use ( $fixPath ) {
147 if ( is_string( $value[
'file'] ) ) {
148 $fixPath( $value[
'file'] );
149 } elseif ( is_array( $value[
'file'] ) ) {
150 array_walk_recursive( $value[
'file'], $fixPath );
trait OOUIModule
Convenience methods for dealing with OOUI themes and their relations to MW skins.