php - Fatal error: Call to a member function read() on a non-object on LanguageComponent -
i having line in cakephp code: $language = $this->cookie->read('language');
and i'm getting error:
fatal error: phone call fellow member function read() on non-object in c:\apache24\htdocs\cake\app\controller\component\languagecomponent.php on line 27 here languagecomponent.php code
<?php //app::import('component', 'cookie'); class languagecomponent extends object { public $controller = null; public $components = array('cookie'); public $languages = array(); public function initialize($controller) { $this->controller = $controller; if (empty($languages)) { $this->languages = configure::read('config.languages'); } $this->set(); } public function set($language = null) { $savecookie = false; if (empty($language) && isset($this->controller)) { if (!empty($this->controller->params['named']['lang'])) { $language = $this->controller->params['named']['lang']; } elseif (!empty($this->controller->params['url']['lang'])) { $language = $this->controller->params['url']['lang']; } if (!empty($language)) { $savecookie = true; } } if (empty($language)) { $language = $this->cookie->read('language'); if (empty($language)) { $savecookie = true; } } if (empty($language) && !array_key_exists($language, $this->languages)) { $language = configure::read('config.language'); } configure::write('config.language', $language); if ($savecookie) { $this->cookie->write('language', $language, false, '1 year'); } } } ?> where problem be?
wrong parent class
compare code in question:
class languagecomponent extends object { to any core component:
class authcomponent extends component { extending wrong class means none of component constructor logic invoked, , the way components loaded on first access not available.
in process of upgrading?this perchance because language component written 1.x - parent class components changed when 2.x released. mentioned in the 2.0 migration guide:
component required base of operations class components.
php cakephp cookies
No comments:
Post a Comment