function sassy_load_callback in Sassy 7.2
Same name and namespace in other branches
- 7.3 sassy.module \sassy_load_callback()
Called from inside SassParser when a file is trying to be loaded.
Parameters
$file: The file trying to be loaded, eg 'myfile/bla.scss'
Return value
An array of 0 - n filenames to load. If no valid files are found return array() or FALSE
2 string references to 'sassy_load_callback'
- SassyBaseUnitTest::runTest in ./
sassy.test - sassy_parse in ./
sassy.module - Parse a SCSS string and transform it into CSS.
File
- ./
sassy.module, line 148
Code
function sassy_load_callback($file) {
$file = explode('/', $file, 2);
$namespace = '';
// Don't reduce the file array if there is only one element and no namespace
if (count($file) >= 2) {
$namespace = preg_replace('/[^0-9a-z]+/', '_', strtolower(array_shift($file)));
}
# check for implementing modules specific to namespace and invoke looking for a paths array.
foreach (module_implements('sassy_resolve_path_' . $namespace) as $module) {
$hook = $module . '_sassy_resolve_path_' . $namespace;
if (function_exists($hook) && ($paths = call_user_func($hook, $file[0]))) {
return (array) $paths;
}
}
# check for implenting modules for the generic hook, looking for a path array.
foreach (module_implements('sassy_resolve_path') as $module) {
$hook = $module . '_sassy_resolve_path';
if (function_exists($hook) && ($paths = call_user_func($hook, $file, $namespace))) {
return (array) $paths;
}
}
# check for modules or themes named $namespace and try directly finding a file.
if ($namespace != 'general' && $namespace != 'sprites' && $namespace != 'typography' && $namespace != 'links' && $namespace != 'lists' && $namespace != 'utilities' && $namespace != 'css' && $namespace != 'text' && $namespace != 'css3' && $namespace != 'tables' && $namespace != 'color') {
$module_exists_in_filesystem = (bool) drupal_get_filename('module', $namespace, NULL, FALSE);
if ($module_exists_in_filesystem) {
$path = drupal_get_path('theme', $namespace);
}
else {
$theme_exists_in_filesystem = (bool) drupal_get_filename('theme', $namespace, NULL, FALSE);
if ($theme_exists_in_filesystem) {
$path = drupal_get_path('theme', $namespace);
}
else {
$path = false;
}
}
}
else {
$path = NULL;
}
if (!$path && $namespace == 'public') {
$path = 'public:/';
}
if ($path) {
$path = $path . '/' . $file[0];
if (file_exists($path)) {
$path = drupal_realpath($path);
return array(
$path,
);
}
}
return FALSE;
}