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());
 }
Beispiel #2
0
 public function url_stat($path, $flags)
 {
     if (preg_match("'^k2://(.+)\$'i", $path)) {
         try {
             $stat = @stat(static::$kernel->getResource($this->getResourceLocation($path)));
         } catch (\Exception $e) {
             if (!($flags & STREAM_URL_STAT_QUIET)) {
                 trigger_error(sprintf('Unable to find "%s": %s', $path, $e->getMessage()), E_USER_ERROR);
             }
             return [];
         }
     } else {
         if (!($flags & STREAM_URL_STAT_QUIET)) {
             trigger_error('Invalid K2 resource URL: "' . $path . '"', E_USER_ERROR);
         }
         return [];
     }
     if ($stat === false) {
         if (!($flags & STREAM_URL_STAT_QUIET)) {
             $error = error_get_last();
             $message = isset($error['message']) ? ': ' . trim($error['message']) : '';
             trigger_error(sprintf('Unable to get stat of "%s"%s', $path, $message), E_USER_ERROR);
         }
         return [];
     }
     return $stat;
 }
Beispiel #3
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;
 }
 public function __construct(KernelInterface $kernel)
 {
     parent::__construct();
     $this->directory = $kernel->getProjectDirectory();
 }
Beispiel #5
0
 public function __construct(KernelInterface $kernel)
 {
     parent::__construct();
     $this->config = $kernel->getConfiguration();
 }