Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected function _set_default_controller() {
- if (empty($this->default_controller)) {
- show_error('Unable to determine what should be displayed. A default route has not been specified in the routing file.');
- }
- // Is the method being specified?
- if (sscanf($this->default_controller, '%[^/]/%s', $class, $method) !== 2) {
- $method = 'index';
- }
- //disini cek terlebih dahulu controller yang dilempar sama router itu direktori atau bukan
- //cth login/auth dia cek apakah login itu merupakan direktori di folder controllersnya
- if( is_dir(APPPATH.'controllers/'.$class) ) {
- //kalo login tadi merupakan folder disini kita set login tersebut sebagai direktori
- $this->set_directory($class);
- //dan method dari yang hasil lemparan router tadi kita jadikan class
- $class = $method;
- //lalu kita cek ulang apakah method ini masih merupakan folder atau bukan
- //karena disini saya cuman butuh 1 folder jadi disini saya asumsikan hanya bisa didalam 1 folder saja
- //dan kalo auth itu memang class maka kita buat method dengan nama index
- if (sscanf($method, '%[^/]/%s', $class, $method) !== 2) {
- $method = 'index';
- }
- }
- if ( ! file_exists(APPPATH.'controllers/'.$this->directory.ucfirst($class).'.php')) {
- // This will trigger 404 later
- return;
- }
- $this->set_class($class);
- $this->set_method($method);
- // Assign routed segments, index starting from 1
- $this->uri->rsegments = array(
- 1 => $class,
- 2 => $method
- );
- log_message('debug', 'No URI present. Default controller set.');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement