From fca3887393c5f388879a128355846f2755469aa4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sat, 28 Mar 2015 01:44:47 +0100 Subject: [PATCH] ResourceLoaderImageModule: Rename 'image' in descriptors to 'file' Like in OOjs UI. Less confusing. No one is using this yet. Bug: T93669 Change-Id: Ib1c9af96b46ba660b3697d272129e071da1fdf18 --- includes/resourceloader/ResourceLoaderImage.php | 4 ++-- includes/resourceloader/ResourceLoaderImageModule.php | 4 ++-- .../resourceloader/ResourceLoaderImageModuleTest.php | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/includes/resourceloader/ResourceLoaderImage.php b/includes/resourceloader/ResourceLoaderImage.php index 4a1f4093c4..4b16a121b5 100644 --- a/includes/resourceloader/ResourceLoaderImage.php +++ b/includes/resourceloader/ResourceLoaderImage.php @@ -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; } diff --git a/includes/resourceloader/ResourceLoaderImageModule.php b/includes/resourceloader/ResourceLoaderImageModule.php index 57731fa209..28aebdf99d 100644 --- a/includes/resourceloader/ResourceLoaderImageModule.php +++ b/includes/resourceloader/ResourceLoaderImageModule.php @@ -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 ); diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php index 5aa1237942..a316a17ca0 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php @@ -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', -- 2.20.1