Cara Menggunakan fungsi _remap di codeigniter

Fungsi _remap() digunakan untuk meremap ulang fungsi tanpa menggunakan rule router. Keuntungannya adalah kita bisa melakukan operasi logic pada saat kita me-route sebuah controller.

Permasalahanya adalah fungsi remap hanya memiliki 1 parameter yaitu nama fungsi dari controller yang akan di eksekusi. berikut adalah solusinya :d

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function _remap($func)
{
      //cek hak akses
      $this->access->cek_hak_akses(get_class($this),$func);
 
	if (method_exists($this,$func))
	{
	    $URI =& load_class('URI');
	    call_user_func_array(array(&$this, $func), array_slice($URI->rsegments, 2));
	}
	else
	{
	    show_404(get_class($this).'/'.$func);
	}
}

Random Posts

    About ibnoe
    Hi, my name is Ibnu Daqiqil Id and I’m an indonesian Web Developer. I love creating simple, unique and easy-to-use web application and what most counts for me is to work with people who are passionate about what they do.

    Leave a Reply

    Tags

    ,

    Postingan Terbaru

    Copyright © 2010 Tutorial PHP Jquery Codeigniter Ajax javascript