You are here

function _less_watch in Less CSS Preprocessor 7.2

Same name and namespace in other branches
  1. 8 includes/less.watch.inc \_less_watch()
  2. 7.4 includes/less.watch.inc \_less_watch()
  3. 7.3 less.watch.inc \_less_watch()
1 string reference to '_less_watch'
less_menu in ./less.module
Implements hook_menu().

File

./less.module, line 512
Handles compiling of .less files.

Code

function _less_watch() {
  $files = (array) $_POST['files'];
  $changed_files = array();
  foreach ($files as $file) {
    if ($cache = cache_get('less:watch:' . drupal_hash_base64($file))) {
      $cached_data = $cache->data;
      $current_mtime = filemtime($cached_data['output_file']);
      $styles = array(
        '#items' => array(
          $cached_data['data'] => $cached_data,
        ),
      );
      $styles = _less_pre_render($styles);
      if (filemtime($styles['#items'][$cached_data['data']]['data']) > $current_mtime) {
        $changed_files[] = array(
          'old_file' => $file,
          'new_file' => file_create_url($styles['#items'][$cached_data['data']]['data']),
        );
      }
    }
  }
  drupal_json_output($changed_files);
}