Overwrite the _setupFile function so placeholder images can be shown instead of broken images


@param string $originalFile
@param string $cacheFile
979006
protected function setupFile($originalFile, $cacheFile)
    {
        if (count($this->filters) > 0) {
            $this->checkNumberOfAllowedFilters($cacheFile);
            if ($this->options['checkReferrer']) {
                $this->checkReferrer();
            }
        }

        if (! file_exists($originalFile)) {
            // If we are using a placeholder and that exists, use it!
            if ($this->placeholder && file_exists($this->placeholder)) {
                $originalFile = $this->placeholder;
            }
        }

        parent::setupFile($originalFile, $cacheFile);
    }
745311
public function setCachePath($cachePath='')
    {
        if ($this->cache) {
            if (empty($cachePath)) {
                $this->cachePath = $this->templatesPath.'cache/';
            } else {
                $this->cachePath = $cachePath;
            }
            if (!is_readable($this->cachePath) || !is_writeable($this->cachePath)) {
                $this->error("Template Cache Path ({$this->cachePath}) does not exist or is not readable & writeable.");
            }
        } else {
            $this->cachePath = null;
        }
    }
947235
protected function insertUseStatement(File $phpcsFile, array $useStatement): void
    {
        $existingStatements = $this->existingStatements;
        if ($existingStatements) {
            $lastOne = array_pop($existingStatements);

            $lastUseStatementIndex = $lastOne['end'];
        } else {
            $namespaceStatement = $this->getNamespaceStatement($phpcsFile);

            $lastUseStatementIndex = $namespaceStatement['end'];
        }

        $phpcsFile->fixer->addNewline($lastUseStatementIndex);
        $phpcsFile->fixer->addContent($lastUseStatementIndex, $this->generateUseStatement($useStatement));
    }
780311
protected function checkCache($originalFile, $cacheFile)
    {
        if (! file_exists($cacheFile) || ! file_exists($originalFile)) {
            return false;
        }

        $cacheFileLastModified = filemtime($cacheFile);
        if (filemtime($originalFile) > $cacheFileLastModified) {
            return false;
        }

        if ($this->lastModifiedDate < $cacheFileLastModified) {
            $this->lastModifiedDate = $cacheFileLastModified;
        }

        return file_get_contents($cacheFile);
    }
914175
public function renameFileInFileSystem(File $originFile, File $newFile)
	{
		$originFilePath = $this->getFilesystemPath($originFile);
		
		if ( ! file_exists($originFilePath)) {
			// silently exit to allow to rename physically non existing files
			return false;
		}

		$newPath = $this->getFilesystemPath($newFile);
		
		if (! rename($originFilePath, $newPath)) {
			throw new Exception\RuntimeException('File renaming failed');
		}

		if ($originFile instanceof Image) {
			
			$sizes = $originFile->getImageSizeCollection();
			
			foreach ($sizes as $size) {
				
				$sizeName = $size->getName();
				
				$newPath = $this->getImagePath($newFile, $sizeName);
				
				$currentPath = $this->getImagePath($originFile, $sizeName);
			
				rename($currentPath, $newPath);
			}
		}
	}
167771
public static function setCachePath($pathCacheFile)
    {
        self::$cacheEnable = false;

        if (!empty($pathCacheFile) && file_exists($pathCacheFile)) {
            self::$cacheEnable = true;
            self::$cachePath   = $pathCacheFile;
        }
        elseif (!empty($pathCacheFile) && !file_exists(dirname($pathCacheFile))) {
            self::$cacheEnable = false;
            self::$cachePath   = $pathCacheFile;
        }
        elseif (!empty($pathCacheFile) && touch($pathCacheFile)) {
            unlink($pathCacheFile);
            self::$cacheEnable = true;
            self::$cachePath   = $pathCacheFile;
        }
    }
937587
private static function resizeImage($sourceFile, $destFile, $width) {
    $image = new \Gumlet\ImageResize($sourceFile);
    $image->resizeToWidth($width);
    $image->save($destFile);
  }
555749
public static function startFromFileCache(string $cacheFile)
    {
        self::start(
                function() use($cacheFile)
                {
                    if (file_exists($cacheFile)) {
                        return unserialize(file_get_contents($cacheFile));
                    }

                    return [];
                },
                function(array $annotationData) use($cacheFile)
                {
                    file_put_contents($cacheFile, serialize($annotationData));
                }
        );
    }
917871
private Properties loadCacheData(final File cacheFile) {
        final Properties cacheProperties = new Properties();
        if (cacheFile.isFile()) {
            //try to load cache data if present
            try {
                final FileInputStream fileInputStream = new FileInputStream(cacheFile);
                try {
                    cacheProperties.load(fileInputStream);
                } finally {
                    fileInputStream.close();
                }
            } catch (IOException e) {
                logger.debug("failed to load cache data from file: " + cacheFile);
            }
        }
        return cacheProperties;
    }
219812
public function downloadSubtitle($url, $originalFile)
    {
        $subtitleFile    = preg_replace("/\\.[^.\\s]{3,4}$/", "", $originalFile) . '.srt';
        $subtitleContent = gzdecode(file_get_contents($url));

        file_put_contents($subtitleFile, $subtitleContent);
    }
557393
protected function createCacheFile()
    {
        $this->createCacheDir();

        $cacheFilePath = $this->getCacheFile();

        if ( ! file_exists($cacheFilePath)) {
            touch($cacheFilePath);
        }
    }
146639
protected function fixRelativePaths($content, $originalFile)
    {
        $cssParserSettings = CssSettings::create()->withMultibyteSupport(false);
        $cssParser = new CssParser($content, $cssParserSettings);
        $cssDocument = $cssParser->parse();

        $cssBlocks = $cssDocument->getAllValues();

        $this->fixUrls($cssBlocks, $originalFile);

        return $cssDocument->render();
    }
82520
public function ClearCache($ConfigFile) {
      $FileKey = sprintf(Gdn_Configuration::CONFIG_FILE_CACHE_KEY, $ConfigFile);
      if (Gdn::Cache()->Type() == Gdn_Cache::CACHE_TYPE_MEMORY && Gdn::Cache()->ActiveEnabled()) {
         Gdn::Cache()->Remove($FileKey,array(
             Gdn_Cache::FEATURE_NOPREFIX => TRUE
         ));
      }
   }
1083791
private function checkCacheValid( $cacheFile )
	{
		if ( file_exists( $cacheFile ) && ( filemtime( $cacheFile ) >  filemtime( $this->filePath ) ) )
		{
			return true;
		}

		return false;
	}
469528
private static function setCache(Cache &$cacheToChange = null, Cache $cache = null, $namespace = null)
    {
        if ($namespace === null) {
            $namespace = self::$cacheDefaultNamespace;
        }
        if (!is_string($namespace)) {
            throw new \InvalidArgumentException("The namespace must be a string.");
        }

        $cacheToChange = $cache;
        if ($cache !== null) {
            $cacheToChange->setNamespace($namespace);
        }
    }
516950
function append(configure) {
  fs.appendFileSync(configure.dist, JSON.stringify(configure.cacheArray).slice(1, -1));
}
1320485
public function saveCacheFile()
    {
        if ($this->store !== null) {
            file_put_contents($this->cacheFile, $this->createCache($this->store), LOCK_EX);
            $this->store = null;
        }
    }