public function write($path, $contents, $blocking = false)
{
$flockFlags = $blocking ? LOCK_EX : LOCK_EX | LOCK_NB;
$file = fopen($path, 'c');
if (!flock($file, $flockFlags)) {
fclose($file);
throw new IOException("Could not aquire file lock for file: {$path}");
}
ftruncate($file, 0);
fwrite($file, $contents);
fflush($file);
flock($file, LOCK_UN | LOCK_NB);
fclose($file);
}
protected function generateDispatchData() { $data = $this->routeCollector->getData(); if ($this->cachePath !== null) { $filesys = new LockingFilesystem(); $php = '<?php return ' . var_export($data, true) . ";\n"; $filesys->write($this->cachePath, $php); } return $data; }