/**
* @param string $name
* @return string
*/
public function link($name)
{
$path = $this->cache->load([$name, $this->debugMode]);
$files = $this->files[$name];
$files = is_string($files) ? [$files] : $files;
if ($path === NULL) {
$unpackedFiles = $this->unpack($name, $files);
$time = $this->getModifyTime($unpackedFiles);
$path = $this->genDir . '/' . $this->getOutputFilename($name, $unpackedFiles, $time, $this->debugMode);
$this->cache->save([$name, $this->debugMode], $path);
}
$genFile = "{$this->wwwDir}/{$path}";
if (!file_exists($genFile) || $this->debugMode && filemtime($genFile) < (isset($time) ? $time : ($time = $this->getModifyTime($this->unpack($name, $files))))) {
$start = microtime(TRUE);
$parsedFiles = $this->compile($this->unpack($name, $files), $genFile);
if ($this->debugMode) {
$this->statistics[$name]['time'] = microtime(TRUE) - $start;
$this->statistics[$name]['parsedFiles'] = $parsedFiles;
}
}
if ($this->debugMode) {
$unpackedFiles = $this->unpack($name, $files);
$this->statistics[$name]['size'] = filesize($genFile);
$this->statistics[$name]['file'] = count($unpackedFiles) > 1 ? $unpackedFiles : reset($unpackedFiles);
$this->statistics[$name]['date'] = isset($time) ? $time : ($time = $this->getModifyTime($unpackedFiles));
$this->statistics[$name]['path'] = $path;
}
return $path;
}