ResourceLoader: Move safeFilemtime() to ResourceLoaderModule.
authorTimo Tijhof <ttijhof@wikimedia.org>
Wed, 5 Dec 2012 07:37:48 +0000 (08:37 +0100)
committerTimo Tijhof <ttijhof@wikimedia.org>
Sun, 16 Dec 2012 22:13:04 +0000 (23:13 +0100)
This is a useful method not just for inside and sub classes of
ResourceLoaderFileModule (i.e. it could've been useful in
VisualEditor's ResourceLoaderModule class as well)

Also moved up getTargets() to be in the right section (looking at
the file as a whole).

Change-Id: If696ffbdc5aa7f0a51603bcf9d52adab38b9c686

includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderModule.php

index ffa3046..08e1620 100644 (file)
@@ -649,23 +649,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                );
        }
 
-       /**
-        * Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist
-        * but returns 1 instead.
-        * @param $filename string File name
-        * @return int UNIX timestamp, or 1 if the file doesn't exist
-        */
-       protected static function safeFilemtime( $filename ) {
-               if ( file_exists( $filename ) ) {
-                       return filemtime( $filename );
-               } else {
-                       // We only ever map this function on an array if we're gonna call max() after,
-                       // so return our standard minimum timestamps here. This is 1, not 0, because
-                       // wfTimestamp(0) == NOW
-                       return 1;
-               }
-       }
-
        /**
         * Get whether CSS for this module should be flipped
         * @param $context ResourceLoaderContext
index 0e170fb..b3e1f93 100644 (file)
@@ -289,6 +289,16 @@ abstract class ResourceLoaderModule {
                return array();
        }
 
+       /**
+        * Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile']
+        * Default implementation hardcodes 'desktop'.
+        *
+        * @return array of strings
+        */
+       public function getTargets() {
+               return array( 'desktop' );
+       }
+
        /**
         * Get the files this module depends on indirectly for a given skin.
         * Currently these are only image files referenced by the module's CSS.
@@ -451,12 +461,19 @@ abstract class ResourceLoaderModule {
        }
 
        /**
-        * Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile']
-        * Default implementation hardcodes 'desktop'.
-        *
-        * @return array of strings
+        * Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist
+        * but returns 1 instead.
+        * @param $filename string File name
+        * @return int UNIX timestamp, or 1 if the file doesn't exist
         */
-       public function getTargets() {
-               return array( 'desktop' );
+       protected static function safeFilemtime( $filename ) {
+               if ( file_exists( $filename ) ) {
+                       return filemtime( $filename );
+               } else {
+                       // We only ever map this function on an array if we're gonna call max() after,
+                       // so return our standard minimum timestamps here. This is 1, not 0, because
+                       // wfTimestamp(0) == NOW
+                       return 1;
+               }
        }
 }