blog yang berisi berbagai macam cara ampuh

Cara Mengatasi CodeIgniter HMVC object_to_array() error


Ketika Instalasi Modular Extension di CodeIgniter, muncul pesan error seperti ini :
An uncaught Exception was encountered
Type: Error
 Message: Call to undefined method MY_Loader::_ci_object_to_array()
 Filename: /Users/k1ut2/Sites/nine.dev/application/third_party/MX/Loader.php
 Line Number: 300
 Backtrace:
 File: /Users/k1ut2/Sites/nine.dev/application/controllers/Welcome.php Line: 23 Function: view
 File: /Users/k1ut2/Sites/nine.dev/index.php Line: 315 Function: require_once
Untuk memperbaiki Error di atas maka :

1. Buka application/third_party/MX/Loader.php
2. Cari function public function view($view, $vars = array(), $return = FALSE)
    Cari… (Line 300)
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
Ganti kode tersebut dengan :
if (method_exists($this, '_ci_object_to_array'))
{
    return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));

} else {
    return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
}
Selesai.

Semoga bermanfaat.