You are here

function _less_inc in Less CSS Preprocessor 7.2

Same name and namespace in other branches
  1. 8 less.module \_less_inc()
  2. 6.2 less.module \_less_inc()
  3. 7.4 less.module \_less_inc()
  4. 7.3 less.module \_less_inc()

Finds and loads the lessphp library

2 calls to _less_inc()
less_requirements in ./less.install
Implementation of hook_requirements().
_less_pre_render in ./less.module
Processes .less files
1 string reference to '_less_inc'
less_requirements in ./less.install
Implementation of hook_requirements().

File

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

Code

function _less_inc() {
  static $loaded = NULL;
  if (!isset($loaded)) {

    // Locations to check for lessphp, by order of preference.
    $include_locations = array();

    // Composer created path.
    $include_locations[] = dirname(__FILE__) . '/vendor/autoload.php';

    // Ensure libraries module is loaded.
    module_load_include('module', 'libraries');
    if (function_exists('libraries_get_path')) {

      // Add libraries supported path.
      $include_locations[] = libraries_get_path('lessphp') . '/lessc.inc.php';
    }

    // Add legacy path as final possible location.
    $include_locations[] = dirname(__FILE__) . '/lessphp/lessc.inc.php';
    foreach ($include_locations as $include_location) {
      if (is_file($include_location)) {
        require_once $include_location;
        break;
      }
    }
    $loaded = class_exists('lessc', TRUE) && version_compare(lessc::$VERSION, 'v0.3.7', '>=');
  }
  return $loaded;
}