Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\HttpKernel\CacheWarmer; Chris@0: Chris@0: /** Chris@0: * Abstract cache warmer that knows how to write a file to the cache. Chris@0: * Chris@0: * @author Fabien Potencier Chris@0: */ Chris@0: abstract class CacheWarmer implements CacheWarmerInterface Chris@0: { Chris@0: protected function writeCacheFile($file, $content) Chris@0: { Chris@17: $tmpFile = @tempnam(\dirname($file), basename($file)); Chris@0: if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { Chris@0: @chmod($file, 0666 & ~umask()); Chris@0: Chris@0: return; Chris@0: } Chris@0: Chris@0: throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); Chris@0: } Chris@0: }