/**
  * Construct an ResourceFileCache from a context
  * @param ResourceLoaderContext $context
  * @return ResourceFileCache
  */
 public static function newFromContext(ResourceLoaderContext $context)
 {
     $cache = new self();
     if ($context->getImage()) {
         $cache->mType = 'image';
     } elseif ($context->getOnly() === 'styles') {
         $cache->mType = 'css';
     } else {
         $cache->mType = 'js';
     }
     $modules = array_unique($context->getModules());
     // remove duplicates
     sort($modules);
     // normalize the order (permutation => combination)
     $cache->mKey = sha1($context->getHash() . implode('|', $modules));
     if (count($modules) == 1) {
         $cache->mCacheWorthy = true;
         // won't take up much space
     }
     return $cache;
 }