2013-02-09 38 views
0

我想在我的Laravel 3.2中的基本控制器中獲取當前的控制器名稱,但它返回null。在我的主控制器中沒有問題。Base_Controller:在Laravel中訪問當前的控制器名稱

我怎樣才能得到這個值在我的Base_Controller

<?php 

class Base_Controller extends Controller { 

    public $page_data = array(); 


    public function __call($method, $parameters) { 
     return Response::error('404'); 
    } 


    public function __construct() { 


     $this->page_data['body_id'] = Request::$route->controller; 


     parent::__construct(); 
    } 

} 

回答

0

爲什麼不使用get_called_class()如果您有PHP 5.3可用,以便您可以獲取控制器類的名稱?這是一個解決方法,雖然並不完全是你在找...

+0

真棒謝謝!無論如何,控制器的行動呢? – i52poutine 2013-02-10 08:52:29

+0

當然,請檢查:[http://stackoverflow.com/questions/2115913/retrieving-the-name-of-the-current-function-in-php](http://stackoverflow.com/questions/2115913/檢索最名稱的最電流函數功能於PHP) – Panais 2013-02-10 08:56:44

相關問題