public function LibsassCompiler::checkLastModifyTime in SCSS/Less Compiler 8
Checks if file was changed.
Parameters
array $source_file: Compilation file info.
Return value
string Last modify timestamp.
Overrides ScssCompilerPluginInterface::checkLastModifyTime
File
- src/
Plugin/ ScssCompiler/ LibsassCompiler.php, line 185
Class
- LibsassCompiler
- Plugin implementation of the Libsass compiler.
Namespace
Drupal\scss_compiler\Plugin\ScssCompilerCode
public function checkLastModifyTime(array &$source_file) {
$last_modify_time = filemtime($source_file['source_path']);
$source_folder = dirname($source_file['source_path']);
$import = [];
$content = file_get_contents($source_file['source_path']);
preg_match_all('/@import(.*);/', $content, $import);
if (!empty($import[1])) {
foreach ($import[1] as $file) {
// Normalize @import path.
$file_path = trim($file, '\'" ');
$pathinfo = pathinfo($file_path);
$extension = '.' . pathinfo($file_path, PATHINFO_EXTENSION);
$filename = $pathinfo['filename'];
$dirname = $pathinfo['dirname'] === '.' ? '' : $pathinfo['dirname'] . '/';
$file_path = $source_folder . '/' . $dirname . $filename . $extension;
$scss_path = $source_folder . '/' . $dirname . '_' . $filename . $extension;
if (file_exists($file_path) || file_exists($file_path = $scss_path)) {
$file_modify_time = filemtime($file_path);
if ($file_modify_time > $last_modify_time) {
$last_modify_time = $file_modify_time;
}
}
}
}
return $last_modify_time;
}