2011-07-08 14 views
0

AppControllerでコンポーネントを使用できないようですか?ここでAppControllerでコンポーネントCookieを使用するCakePHP

class AppController extends Controller { 
    var $helpers = array('Facebook', 'Session', 'Menu', 'Html', 'Form'); // Facebook is a custom helper. 
    var $components = array('Cookie'); 

    function beforeFilter () 
    { 
     $this->Cookie->name = '[removed]'; 
     $this->Cookie->path = '/cake/'; 
     $this->Cookie->domain = 'localhost'; 
     $this->Cookie->key = '[removed]'; 

     $this->_initUser(); 
    } 

    function _initUser ()  // Using this for a cleaner default.ctp 
    { 
     @Controller::loadModel('User'); 

     // DEFINE facebook variables globally 
     $GLOBALS['APP_ID'] = '[removed]'; 
     $GLOBALS['APP_SECRET'] = '[removed]'; 
     $GLOBALS['REDIRECT_URI'] = 'http://localhost/cake'; 

     // Check if logged in with Facebook. 
     if($this->Cookie->read('User') == null && isset($_GET['code'])) // Line 57. 
. 
. 
. 

はPHPが投げているエラーです:

Notice (8): Undefined property: View::$Cookie [APP\app_controller.php, line 57]Code 
     // Check if logged in with Facebook. 
     if($this->Cookie->read('User') == null && isset($_GET['code'])) AppController::_initUser() - APP\app_controller.php, line 57 
include - APP\views\layouts\default.ctp, line 47 
View::_render() - CORE\cake\libs\view\view.php, line 731 
View::renderLayout() - CORE\cake\libs\view\view.php, line 489 
View::render() - CORE\cake\libs\view\view.php, line 435 
Controller::render() - APP\controller.php, line 909 
PagesController::display() - APP\controllers\pages_controller.php, line 83 
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 204 
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 171 
[main] - APP\webroot\index.php, line 83 

Fatal error: Call to a member function read() on a non-object in C:\xampp\htdocs\cake\app\app_controller.php on line 57 

助けてください、私は何をすべきかについては考えています!

+0

あなたが呼び出している 'のAppController :: _ initUser'view‽ – deceze

+0

からありません:(私はのbeforeFilter自体から_initUser''への呼び出しを追加するまで、私がいたわけ。 は今、それをいくつかのテストを行い、結論しようとしますどこに問題があるのか​​。 – Angad

答えて

0

Aha!私はそれを最終的に修正した。問題は、私のFacebookコンポーネントが誤ってclass FacebookHelperを読み取ったことでした。

私はこの問題を修正してから、残りのAppControllerを正常に実行し続けました。

もう一度深夜までコード化するつもりはありません。

関連する問題