Error when accessing base controller variable |
Hi there, I'm hoping someone can help. I've got a class that I'm using in my controllers and libraries to handle settings that are stored in the database. When accessing them in my controller via $this->settings->get('blah'), I have no problems at all.
However, when I pass $this->settings in the controller's __construct() to my template library, it's passing a null value and I get this error: Quote:TypeError I've loaded the library in the base controller as shown below. This is my BaseController: PHP Code: public $session, $settings; This is the Settings class: PHP Code: class Settings { And finally my controller itself: PHP Code: class AccountController extends BaseController Any help would be greatly appreciated! Thanks.
WebDevZone - A new, friendly web development community
this is how i'm setting some BaseController , class member properties
public function __construct() { helper(['text', 'date']); $this->theTime = now('Australia/Victoria'); $this->theDate = date("d/m/Y",$this->theTime); }
Your issue is the class constructor will run before initController method. Use this instead.
PHP Code: class AccountController extends BaseController |
Welcome Guest, Not a member yet? Register Sign In |