/**
  * Helper method to get local filesystem path for this file
  *
  * @param AssetContainer $asset
  * @return string
  */
 public static function getLocalPath(AssetContainer $asset)
 {
     if ($asset instanceof Folder) {
         return self::base_path() . '/' . $asset->getFilename();
     }
     if ($asset instanceof File) {
         $asset = $asset->File;
     }
     // Extract filesystem used to store this object
     /** @var AssetStoreTest_SpyStore $assetStore */
     $assetStore = Injector::inst()->get('AssetStore');
     $fileID = $assetStore->getFileID($asset->Filename, $asset->Hash, $asset->Variant);
     $filesystem = $assetStore->getProtectedFilesystem();
     if (!$filesystem->has($fileID)) {
         $filesystem = $assetStore->getPublicFilesystem();
     }
     /** @var Local $adapter */
     $adapter = $filesystem->getAdapter();
     return $adapter->applyPathPrefix($fileID);
 }
 public function loadFromContainer(AssetContainer $assetContainer)
 {
     // If we're working with image resampling, things could take a while.  Bump up the time-limit
     increase_time_limit_to(300);
     $this->resetResource();
     // Skip non-existant files
     if (!$assetContainer->exists()) {
         return;
     }
     // Skip if failed before
     $filename = $assetContainer->getFilename();
     $hash = $assetContainer->getHash();
     $variant = $assetContainer->getVariant();
     if ($this->failedResample($filename, $hash, $variant)) {
         return;
     }
     // Mark as potentially failed prior to creation, resetting this on success
     $content = $assetContainer->getString();
     $image = imagecreatefromstring($content);
     if ($image === false) {
         $this->markFailed($filename, $hash, $variant);
         return;
     }
     imagealphablending($image, false);
     imagesavealpha($image, true);
     // save alphablending setting (important)
     $this->setImageResource($image);
 }