CakePHP 2.3で、Sessionコンポーネントをカスタムコンポーネントとして組み込もうとしています。
しかし、Sessionコンポーネント関数をコールすると、下記のエラーが表示されます。
lang
1Fatal error: Call to a member function read() on a non-object in ...\app\Controller\Component\ListComponent.php on line 7
ListComponentはこのようになっています。
lang
1<?php 2App::uses('Component', 'Controller'); 3class ListComponent extends Component { 4 public $components = array('Session'); 5 6 function hasData() { 7 $shelves = $this->Session->read('data'); 8 return $shelves != null && count($shelvres) > 0; 9 } 10 11} 12?> 13 14<?php 15class PickupController extends AppController { 16 public $name = 'basket'; 17 public $components = array('List', 'Email'); 18 19 function beforeFilter() { 20 parent::beforeFilter(); 21 if ($this->List->hasItems()) { 22 $this->Auth->allow('add_item', 'remove_item', 'list'); 23 } else { 24 $this->Auth->allow('add_item', 'remove_item', 'list', 'make'); 25 } 26 } 27} 28 29?>
エラーを吐かせないためにはどうすればいいですか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。