Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions Controllerlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,23 @@
*
* @author Peter Prins
*/
class ControllerList {



class ControllerList
{


/**
* Codeigniter reference
*/
private $CI;


/**
* Define EXT as your controller file extension.
* Defining in class is more secure than defining global.
*/
const EXT = '.php';

/**
* Array that will hold the controller names and methods
*/
Expand Down Expand Up @@ -63,12 +73,12 @@ private function setControllers() {
// if the value in the loop is a directory loop through that directory
if(is_dir($controller)) {
// Get name of directory
$dirname = basename($controller, EXT);
$dirname = basename($controller, self::EXT);

// Loop through the subdirectory
foreach(glob(APPPATH . 'controllers/'.$dirname.'/*') as $subdircontroller) {
// Get the name of the subdir
$subdircontrollername = basename($subdircontroller, EXT);
$subdircontrollername = basename($subdircontroller, self::EXT);

// Load the controller file in memory if it's not load already
if(!class_exists($subdircontrollername)) {
Expand All @@ -87,7 +97,7 @@ private function setControllers() {
}
else if(pathinfo($controller, PATHINFO_EXTENSION) == "php"){
// value is no directory get controller name
$controllername = basename($controller, EXT);
$controllername = basename($controller, self::EXT);

// Load the class in memory (if it's not loaded already)
if(!class_exists($controllername)) {
Expand All @@ -110,4 +120,4 @@ private function setControllers() {
}
}
}
// EOF
// EOF