| 1 |
<?php |
| 2 |
|
| 3 |
namespace MailPoet\Config; |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) exit; |
| 6 |
|
| 7 |
|
| 8 |
class TwigFileSystemCache extends \MailPoetVendor\Twig\Cache\FilesystemCache { |
| 9 |
|
| 10 |
private $directory; |
| 11 |
|
| 12 |
public function __construct( |
| 13 |
string $directory, |
| 14 |
int $options = 0 |
| 15 |
) { |
| 16 |
$this->directory = \rtrim($directory, '\\/') . '/'; |
| 17 |
parent::__construct($directory, $options); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* The original FileSystemCache of twig generates the key depending on PHP_VERSION. |
| 22 |
* We need to produce the same key regardless of PHP_VERSION. Therefore, we |
| 23 |
* overwrite this method. |
| 24 |
**/ |
| 25 |
public function generateKey(string $name, string $className): string { |
| 26 |
$hash = \hash('sha256', $className); |
| 27 |
return $this->directory . $hash[0] . $hash[1] . '/' . $hash . '.php'; |
| 28 |
} |
| 29 |
} |
| 30 |
|