-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModuleHelper.php
53 lines (42 loc) · 1.11 KB
/
ModuleHelper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
class Speedy_ModuleHelper{
public static function getAllModuleDirectories($childDir){
$returnVal = array();
foreach(Speedy_ModuleHelper::getAllModules() as $module){
$path = APPLICATION_PATH . '/modules/' . $module . '/' . $childDir;
if(is_dir($path)){
$returnVal[] = $path;
}
}
return $returnVal;
}
public static function getAllModuleFiles($childFile){
$returnVal = array();
foreach(Speedy_ModuleHelper::getAllModules() as $module){
$path = APPLICATION_PATH . '/modules/' . $module . '/' . $childFile;
if(is_file($path)){
$returnVal[] = $path;
}
}
return $returnVal;
}
protected static $_allModules = null;
public static function getAllModules(){
if(self::$_allModules == null){
self::$_allModules = array();
$path = APPLICATION_PATH . '/modules/';
if($handle = opendir($path)){
while(($file = readdir($handle)) !== false){
if($file == '.' or $file == '..'){
continue;
}
$fullPath = $path . $file;
if(is_dir($fullPath)){
self::$_allModules[] = $file;
}
}
}
}
return self::$_allModules;
}
}