PhpFilesAdapter.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Cache\Adapter;
  11. use Symfony\Component\Cache\Exception\CacheException;
  12. use Symfony\Component\Cache\PruneableInterface;
  13. use Symfony\Component\Cache\Traits\PhpFilesTrait;
  14. class PhpFilesAdapter extends AbstractAdapter implements PruneableInterface
  15. {
  16. use PhpFilesTrait;
  17. /**
  18. * @throws CacheException if OPcache is not enabled
  19. */
  20. public function __construct(string $namespace = '', int $defaultLifetime = 0, string $directory = null)
  21. {
  22. if (!static::isSupported()) {
  23. throw new CacheException('OPcache is not enabled');
  24. }
  25. parent::__construct('', $defaultLifetime);
  26. $this->init($namespace, $directory);
  27. $e = new \Exception();
  28. $this->includeHandler = function () use ($e) { throw $e; };
  29. $this->zendDetectUnicode = filter_var(ini_get('zend.detect_unicode'), FILTER_VALIDATE_BOOLEAN);
  30. }
  31. }