public function __construct(KernelInterface $kernel, array $typeMap = [], $enableDebug = false)
 {
     $this->kernel = $kernel;
     $this->typeMap = $typeMap;
     $this->enableDebug = $enableDebug ? true : false;
     $this->instrumentors = $kernel->getInstrumentors();
     $this->cachePath = sprintf('%s/%s/instrument/', $kernel->getCacheDirectory(), $kernel->getContextName());
 }
Exemple #2
0
 public function __construct(KernelInterface $kernel, $timeout = 8)
 {
     $this->contextName = $kernel->getContextName();
     $this->kernel = $kernel;
     $this->timeout = (int) $timeout;
     $dir = Filesystem::createDirectory($kernel->getCacheDirectory() . DIRECTORY_SEPARATOR . $this->contextName);
     $this->file = $dir . DIRECTORY_SEPARATOR . 'cache.php';
     $this->lockFile = $dir . DIRECTORY_SEPARATOR . 'cache.lock';
     if (is_file($this->file)) {
         if (filemtime($this->file) < time() - $this->timeout) {
             $this->needsCheck = true;
         }
         $this->cached = (array) (require $this->file);
     } else {
         $this->modified = true;
         $this->cached = [];
     }
     $this->expired = !is_file($this->file) || filemtime($this->file) < time() - $this->timeout;
 }