You are here

function sassy_registered_includes in Sassy 7.2

Same name and namespace in other branches
  1. 7.3 sassy.module \sassy_registered_includes()

Fetches, caches and returns all SASS / SCSS libraries from all enabled modules and the theme trail.

Return value

An array of all library files, sorted by their basename.

1 call to sassy_registered_includes()
sassy_sassy_resolve_path_sassy in ./sassy.module
Implementation of hook_sassy_resolve_path_NAMESPACE().

File

./sassy.module, line 214

Code

function sassy_registered_includes($base = NULL) {
  $includes =& drupal_static(__FUNCTION__);
  if (!isset($includes)) {
    if ($cache = cache_get('sassy_libraries:' . $GLOBALS['theme_key'])) {
      $includes = $cache->data;
    }
    else {
      $includes = array();

      // Load libraries from all enabled modules and themes.
      foreach (array_merge(module_list(), $GLOBALS['base_theme_info'], array(
        $GLOBALS['theme_info'],
      )) as $info) {
        $type = is_object($info) ? 'theme' : 'module';
        $name = $type == 'theme' ? $info->name : $info;
        $info = $type == 'theme' ? $info->info : system_get_info('module', $name);
        if (!empty($info['sassy'])) {
          foreach ($info['sassy'] as $include) {
            $path = drupal_get_path($type, $name) . '/' . $include;
            if (is_file($path)) {
              $includes[basename($path)][] = $path;
            }
          }
        }
      }
      drupal_alter('sassy_includes', $includes);
      cache_set('sassy_includes:' . $GLOBALS['theme_key'], $includes);
    }
  }
  if (isset($base) && isset($includes[$base])) {
    return $includes[$base];
  }
  else {
    if (!isset($base)) {
      return $includes;
    }
  }
}