2012-08-29 40 views
1

我使用cakephp 2.1版本並創建了一個組件作爲GoogleApiComponent,如下所示。CakePHP調用組件構造函數的參數

class GoogleApiComponent extends Component { 
    public $client; 
    public $analytics; 
    function __construct($prompt = null) { 
     $this->client = new apiClient(); 
     $this->client->setApprovalPrompt($prompt); 
     $this->analytics = new apiAnalyticsService($this->client); 
    } 

}

然後在AppController中,我包括上述組分。

public $components = array('GoogleApi'); 

後一個用戶登錄時,我要檢查在beforeFilter某些條件下()的AppController的方法,按照該條件我不得不改變GoogleAPiComponent構造的參數。 那麼這是如何完成它?工作更明顯..

回答

相關問題