PhpFilesCache.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\Simple;
  11. use Symfony\Component\Cache\Exception\CacheException;
  12. use Symfony\Component\Cache\PruneableInterface;
  13. use Symfony\Component\Cache\Traits\PhpFilesTrait;
  14. class PhpFilesCache extends AbstractCache implements PruneableInterface
  15. {
  16. use PhpFilesTrait;
  17. /**
  18. * @param string $namespace
  19. * @param int $defaultLifetime
  20. * @param string|null $directory
  21. *
  22. * @throws CacheException if OPcache is not enabled
  23. */
  24. public function __construct($namespace = '', $defaultLifetime = 0, $directory = null)
  25. {
  26. if (!static::isSupported()) {
  27. throw new CacheException('OPcache is not enabled');
  28. }
  29. parent::__construct('', $defaultLifetime);
  30. $this->init($namespace, $directory);
  31. $e = new \Exception();
  32. $this->includeHandler = function () use ($e) { throw $e; };
  33. $this->zendDetectUnicode = filter_var(ini_get('zend.detect_unicode'), FILTER_VALIDATE_BOOLEAN);
  34. }
  35. }