ResourceLoaderImageModule: Rename 'image' in descriptors to 'file'
authorBartosz Dziewoński <matma.rex@gmail.com>
Sat, 28 Mar 2015 00:44:47 +0000 (01:44 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sun, 29 Mar 2015 17:38:14 +0000 (19:38 +0200)
Like in OOjs UI. Less confusing. No one is using this yet.

Bug: T93669
Change-Id: Ib1c9af96b46ba660b3697d272129e071da1fdf18

includes/resourceloader/ResourceLoaderImage.php
includes/resourceloader/ResourceLoaderImageModule.php
tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php

index 4a1f409..4b16a12 100644 (file)
@@ -61,11 +61,11 @@ class ResourceLoaderImage {
                } );
                $extensions = array_unique( $extensions );
                if ( count( $extensions ) !== 1 ) {
-                       throw new MWException( 'Image type for various images differs.' );
+                       throw new MWException( "File type for different image files of '$name' not the same." );
                }
                $ext = $extensions[0];
                if ( !isset( self::$fileTypes[$ext] ) ) {
-                       throw new MWException( 'Invalid image type; svg, png, gif or jpg required.' );
+                       throw new MWException( "Invalid file type for image files of '$name' (valid: svg, png, gif, jpg)." );
                }
                $this->extension = $ext;
        }
index 57731fa..28aebdf 100644 (file)
@@ -177,7 +177,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                        $this->imageObjects = array();
 
                        foreach ( $this->images as $name => $options ) {
-                               $imageDesc = is_string( $options ) ? $options : $options['image'];
+                               $fileDescriptor = is_string( $options ) ? $options : $options['file'];
 
                                $allowedVariants = array_merge(
                                        is_array( $options ) && isset( $options['variants'] ) ? $options['variants'] : array(),
@@ -195,7 +195,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule {
                                $image = new ResourceLoaderImage(
                                        $name,
                                        $this->getName(),
-                                       $imageDesc,
+                                       $fileDescriptor,
                                        $this->localBasePath,
                                        $variantConfig
                                );
index 5aa1237..a316a17 100644 (file)
@@ -25,17 +25,17 @@ class ResourceLoaderImageModuleTest extends ResourceLoaderTestCase {
                $commonImageData = array(
                        'advanced' => 'advanced.svg',
                        'remove' => array(
-                               'image' => 'remove.svg',
+                               'file' => 'remove.svg',
                                'variants' => array( 'destructive' ),
                        ),
                        'next' => array(
-                               'image' => array(
+                               'file' => array(
                                        'ltr' => 'next.svg',
                                        'rtl' => 'prev.svg'
                                ),
                        ),
                        'help' => array(
-                               'image' => array(
+                               'file' => array(
                                        'ltr' => 'help-ltr.svg',
                                        'rtl' => 'help-rtl.svg',
                                        'lang' => array(
@@ -44,7 +44,7 @@ class ResourceLoaderImageModuleTest extends ResourceLoaderTestCase {
                                ),
                        ),
                        'bold' => array(
-                               'image' => array(
+                               'file' => array(
                                        'default' => 'bold-a.svg',
                                        'lang' => array(
                                                'en' => 'bold-b.svg',