You are here

protected function ScssCompilerService::checkLastModifyTime in SCSS/Less Compiler 8

Checks if file was changed.

Parameters

array $source_file: Compilation file info.

string $content: Content of source file.

Return value

bool TRUE if file was changed else FALSE.

1 call to ScssCompilerService::checkLastModifyTime()
ScssCompilerService::compile in src/ScssCompilerService.php
Compiles single scss file into css.

File

src/ScssCompilerService.php, line 496

Class

ScssCompilerService
Defines a class for scss compiler service.

Namespace

Drupal\scss_compiler

Code

protected function checkLastModifyTime(array &$source_file, &$content) {

  // If file wasn't changed and compiled css file exists don't recompile it
  // to increase performance. Each plugin has own realization.
  if (empty($this->lastModifyList[$source_file['source_path']]) || !file_exists($source_file['css_path'])) {
    $last_modify_time = filemtime($source_file['source_path']);
    $this->lastModifyList[$source_file['source_path']] = $last_modify_time;
    $this->fileIsModified = TRUE;
    return TRUE;
  }
  $extension = pathinfo($source_file['source_path'], PATHINFO_EXTENSION);
  $plugins = $this->config
    ->get('plugins');
  if (!empty($plugins[$extension])) {
    $compiler = \Drupal::service('plugin.manager.scss_compiler')
      ->getInstanceById($plugins[$extension]);
    $last_modify_time = $compiler
      ->checkLastModifyTime($source_file);
    if ($last_modify_time > $this->lastModifyList[$source_file['source_path']]) {
      $this->lastModifyList[$source_file['source_path']] = $last_modify_time;
      $this->fileIsModified = TRUE;
      return TRUE;
    }
  }
  return FALSE;
}