Skip to content

Commit 9f9aaf4

Browse files
authored
Merge pull request #33 from nguyenanhung/v3.2.0-develop
Update Helper
2 parents aea27da + 839ce67 commit 9f9aaf4

File tree

3 files changed

+48
-54
lines changed

3 files changed

+48
-54
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"nguyenanhung\\CodeIgniter\\BaseREST\\": "thirdParty/REST/"
3636
},
3737
"files": [
38-
"helpers/codeigniter_modular.php",
3938
"helpers/common.php"
4039
]
4140
},

helpers/codeigniter_modular.php

Lines changed: 0 additions & 53 deletions
This file was deleted.

helpers/common.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,54 @@
77
* Date: 09/03/2023
88
* Time: 23:00
99
*/
10+
if (!function_exists('codeigniter_hmvc_module_exists')) {
11+
/**
12+
* Check if a CodeIgniter module with the given name exists
13+
*
14+
* @param $module_name
15+
*
16+
* @return bool
17+
*/
18+
function codeigniter_hmvc_module_exists($module_name)
19+
{
20+
return in_array($module_name, codeigniter_hmvc_modules_list(false));
21+
}
22+
}
23+
if (!function_exists('codeigniter_hmvc_modules_list')) {
24+
/**
25+
* Return the CodeIgniter modules list
26+
*
27+
* @param bool $with_location
28+
*
29+
* @return array
30+
*/
31+
function codeigniter_hmvc_modules_list($with_location = true)
32+
{
33+
if (!function_exists('directory_map'))
34+
{
35+
get_instance()->load->helper('directory');
36+
}
37+
38+
$modules = array();
39+
40+
foreach (Modules::$locations as $location => $offset)
41+
{
42+
$files = directory_map($location, 1);
43+
if (is_array($files))
44+
{
45+
foreach ($files as $name)
46+
{
47+
if (is_dir($location . $name))
48+
{
49+
$modules[] = $with_location ? array($location, $name) : $name;
50+
}
51+
}
52+
}
53+
}
54+
55+
return $modules;
56+
}
57+
}
1058
if (!function_exists('bear_str_to_lower')) {
1159
function bear_str_to_lower($str)
1260
{

0 commit comments

Comments
 (0)