Merge "mediawiki.language: Remove unused private method 'procPLURAL'"
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderImage.php
index d38a175..0adbd0c 100644 (file)
@@ -44,14 +44,18 @@ class ResourceLoaderImage {
         * @param string|array $descriptor Path to image file, or array structure containing paths
         * @param string $basePath Directory to which paths in descriptor refer
         * @param array $variants
+        * @param string|null $defaultColor of the base variant
         * @throws InvalidArgumentException
         */
-       public function __construct( $name, $module, $descriptor, $basePath, $variants ) {
+       public function __construct( $name, $module, $descriptor, $basePath, $variants,
+               $defaultColor = null
+       ) {
                $this->name = $name;
                $this->module = $module;
                $this->descriptor = $descriptor;
                $this->basePath = $basePath;
                $this->variants = $variants;
+               $this->defaultColor = $defaultColor;
 
                // Expand shorthands:
                // [ "en,de,fr" => "foo.svg" ]
@@ -250,7 +254,10 @@ class ResourceLoaderImage {
                if ( $variant && isset( $this->variants[$variant] ) ) {
                        $data = $this->variantize( $this->variants[$variant], $context );
                } else {
-                       $data = file_get_contents( $path );
+                       $defaultColor = $this->defaultColor;
+                       $data = $defaultColor ?
+                               $this->variantize( [ 'color' => $defaultColor ], $context ) :
+                               file_get_contents( $path );
                }
 
                if ( $format === 'rasterized' ) {