//====================================== class Controller_Base extends Controller_Template { public function action_index($modules=NULL) { $result = NULL; // do some stuff return $result; } public function action_do_something_else($data=NULL) { $result = NULL; // do some stuff return $result; } }/// endof base.php //======================================= class Controller_Modules extends Controller_Base { public function action_index($modules=NULL) { $data = array('apple', 'banana', 'cherry'); // following does not work // $result = $this->base->index($data); // $result = $this->base->do_something_else($data); } }///endof modules.php
parent::action_index();
Many thanks for the prompt reply. It works fine on my localhost and will try and update online changes and the download tomorrow. >>> You have to see class extensions as overlays.Harro Verton wrote on Wednesday 7th of September 2011:You have to see class extensions as overlays. Because you define an action_index method in Controller_Modules, you can no longer see the method by the same name in the parent class, Controller_Base. You can still call it, using
parent::action_index(); However, it is not common to do this, unless the method you overload really has the same function, and you are replacing it. If not, use different methods in your base class, so you can call them directly instead of using the 'parent' syntax.
This is how class extensions work in PHP. See http://php.net/manual/en/language.oop5.php, in particular the section on "overloading".John Rutherford wrote on Thursday 8th of September 2011:Is overlay a standard part of OOP or only the Fuel implementation?
It looks like you're new here. If you want to get involved, click one of these buttons!