CacheWarmer.php
1 year ago
CacheWarmerAggregate.php
1 year ago
CacheWarmerInterface.php
2 years ago
WarmableInterface.php
2 years ago
CacheWarmer.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace Matomo\Dependencies\Symfony\Component\HttpKernel\CacheWarmer; |
| 12 | |
| 13 | /** |
| 14 | * Abstract cache warmer that knows how to write a file to the cache. |
| 15 | * |
| 16 | * @author Fabien Potencier <fabien@symfony.com> |
| 17 | */ |
| 18 | abstract class CacheWarmer implements CacheWarmerInterface |
| 19 | { |
| 20 | protected function writeCacheFile(string $file, $content) |
| 21 | { |
| 22 | $tmpFile = @tempnam(\dirname($file), basename($file)); |
| 23 | if (\false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { |
| 24 | @chmod($file, 0666 & ~umask()); |
| 25 | return; |
| 26 | } |
| 27 | throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file)); |
| 28 | } |
| 29 | } |
| 30 |