private function preprocess($file)
{
$ext = pathinfo($file, PATHINFO_EXTENSION);
if (!isset($this->filters[$ext]) || !Helpers::matchMask($file, $this->preprocessMasks)) {
return $this->localDir . $file;
}
$full = $this->localDir . str_replace('/', DIRECTORY_SEPARATOR, $file);
$content = file_get_contents($full);
foreach ($this->filters[$ext] as $info) {
if ($info['cached'] && is_file($tempFile = $this->tempDir . '/' . md5($content))) {
$content = file_get_contents($tempFile);
} else {
$content = call_user_func($info['filter'], $content, $full);
if ($info['cached']) {
file_put_contents($tempFile, $content);
}
}
}
if (empty($info['cached'])) {
$tempFile = tempnam($this->tempDir, 'deploy');
file_put_contents($tempFile, $content);
}
return $tempFile;
}