Reputation: 1700
I have this class in /libraries.
class CI_Decorator extends CI_Controller {
public function __construct() {
parent::__construct();
}
}
The error I get is very weird:
Message: Undefined property: CI_Decorator::$load
Filename: libraries/Form_validation.php
Backtrace:
File: /application/libraries/CI_Decorator.php
And is because I try to get CI_Controller constructor with
parent::__construct();
UPDATE:
I am trying to implement this Decorator but I think was developed for an earlier version of CI.
Upvotes: 0
Views: 38
Reputation: 8964
Change the file name to Decorator.php and in the class file use this.
class Decorator{
//there is no parent so you cannot call a parent constructor
//public function __construct() {
//parent::__construct();
//}
}
Only preface a file (or class) name with "CI_" when you wish to replace one of CodeIgniter's core classes. If a core class with that name does not exist the load will fail.
If you want to extend a native class then you will preface the class and file name with MY_
or with the prefix you set in config.php
$config['subclass_prefix'] = 'YOURPREFIX_';
Extending CI_Controller more than once is frustrating too and you will run into a different but related problem. You will find many answers to that question here on Stack Overflow. In the search box above use the search term "[codeigniter] extending CI_controller" (without the quote marks)
Upvotes: 1