3 * Contain the ObjectFileCache class
7 class ObjectFileCache
extends FileCacheBase
{
9 * Construct an ObjectFileCache from a key and a type
12 * @return ObjectFileCache
14 public static function newFromKey( $key, $type ) {
17 $allowedTypes = self
::cacheableTypes();
18 if ( !isset( $allowedTypes[$type] ) ) {
19 throw new MWException( "Invalid filecache type given." );
21 $cache->mKey
= (string)$key;
22 $cache->mType
= (string)$type;
23 $cache->mExt
= $allowedTypes[$cache->mType
];
29 * Get the type => extension mapping
32 protected static function cacheableTypes() {
33 return array( 'resources-js' => 'js', 'resources-css' => 'css' );
37 * Get the base file cache directory
40 protected function cacheDirectory() {
41 global $wgCacheDirectory, $wgFileCacheDirectory, $wgFileCacheDepth;
42 if ( $wgFileCacheDirectory ) {
43 $dir = $wgFileCacheDirectory;
44 } elseif ( $wgCacheDirectory ) {
45 $dir = "$wgCacheDirectory/object";
47 throw new MWException( 'Please set $wgCacheDirectory in LocalSettings.php if you wish to use the HTML file cache' );