2012-04-26 4 views
1

コントローラがどこにあるのか知りたいですか?(ファイルがどこに入っていて、そのクラスがロードされていて、メソッドが呼び出されています)コアへのマイナーな変更を作成したいので、私は知りたいと思います。CodeIgniterでコントローラが開始された場所

私が実際に必要とするのは、新しいコントローラを呼び出すことをシミュレートすることです。私はHMVCのような技術は必要ありませんが、もっと簡単なことに取り組んでいますが、後で要求されたコントローラとやりとりできる呼び出しコントローラをシミュレートする必要があります。

ローダークラスを使用して新しいコントローラーを呼び出すことができるようにコアのLoaderクラスを既に拡張しましたが、コントローラーがどこから開始されたのかわかりません。

答えて

1

system/core/CodeIgniter.php 317行目から360行目(CodeIgniter 2.1.0)です。

/* 
* ------------------------------------------------------ 
* Call the requested method 
* ------------------------------------------------------ 
*/ 
    // Is there a "remap" function? If so, we call it instead 
    if (method_exists($CI, '_remap')) 
    { 
     $CI->_remap($method, array_slice($URI->rsegments, 2)); 
    } 
    else 
    { 
     // is_callable() returns TRUE on some versions of PHP 5 for private and protected 
     // methods, so we'll use this workaround for consistent behavior 
     if (! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI)))) 
     { 
      // Check and see if we are using a 404 override and use it. 
      if (! empty($RTR->routes['404_override'])) 
      { 
       $x = explode('/', $RTR->routes['404_override']); 
       $class = $x[0]; 
       $method = (isset($x[1]) ? $x[1] : 'index'); 
       if (! class_exists($class)) 
       { 
        if (! file_exists(APPPATH.'controllers/'.$class.'.php')) 
        { 
         show_404("{$class}/{$method}"); 
        } 

        include_once(APPPATH.'controllers/'.$class.'.php'); 
        unset($CI); 
        $CI = new $class(); 
       } 
      } 
      else 
      { 
       show_404("{$class}/{$method}"); 
      } 
     } 

     // Call the requested method. 
     // Any URI segments present (besides the class/function) will be passed to the method for convenience 
     call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2)); 
    } 

でも、あなたがしようとしていることは意味を持ちません。

+0

うまくいけば、私はあなたに伝えます。 –

関連する問題