Last active
December 31, 2015 18:59
-
-
Save puneetkay/8031039 to your computer and use it in GitHub Desktop.
Get current controller and method in CI.
Also, technique to get/manage dynamic global vars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class CI_Controller { | |
private static $instance; | |
public $data = array(); | |
/** | |
* Constructor | |
*/ | |
public function __construct() | |
{ | |
self::$instance =& $this; | |
// Assign all the class objects that were instantiated by the | |
// bootstrap file (CodeIgniter.php) to local class variables | |
// so that CI can run as one big super object. | |
foreach (is_loaded() as $var => $class) | |
{ | |
$this->$var =& load_class($class); | |
} | |
$this->load =& load_class('Loader', 'core'); | |
$this->load->initialize(); | |
//$this->doSomething(); // Preprocessing on all controllers. | |
$this->data['controller'] = $this->router->fetch_class(); | |
$this->data['current'] = $this->router->fetch_method(); | |
log_message('debug', "Controller Class Initialized"); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment