You are here

function _less_check_build in Less CSS Preprocessor 7.4

Same name and namespace in other branches
  1. 8 includes/less.process.inc \_less_check_build()

Check if the file needs to be rebuilt based on changes to @import'ed files.

Parameters

array[] $item:

string $key:

1 string reference to '_less_check_build'
_less_pre_render in ./less.module
Pre-render function for 'style' elements.

File

includes/less.process.inc, line 81
Contains functions related to compiling .less files.

Code

function _less_check_build(&$item, $key) {
  $input_file = $item['less']['input_file'];
  $build_required = FALSE;

  // Set $rebuild if this file or its children have been modified.
  if ($less_file_cache = cache_get('less:devel:' . drupal_hash_base64($input_file))) {

    // Iterate over each file and check if there are any changes.
    foreach ($less_file_cache->data as $filepath => $filemtime) {

      // Only rebuild if there has been a change to a file.
      if (is_file($filepath) && filemtime($filepath) > $filemtime) {
        $build_required = TRUE;
        break;
      }
    }
  }
  else {

    // No cache data, force a rebuild for later comparison.
    $build_required = TRUE;
  }
  $item['less']['build_required'] = $build_required;
}