Documentation:Extending

From TinyMVC

Jump to: navigation, search

[edit] Extending Internal TinyMVC classes

There may be times when you want to extend the core classes of TinyMVC. This is very easy to do. The extendible classes are:

TinyMVC_Controller
TinyMVC_Model
TinyMVC_View

[edit] Learning by example

Lets extend the TinyMVC_Controller class:

myapp/plugins/internal.My_Controller.php

class My_Controller extends TinyMVC_Controller
{
  function __construct()
  {
    parent::__construct();
  }
  // do your class extensions here
}

Then in your controllers, just extend your custom controller:

class Hello_Controller extends My_Controller
{
  function index()
  {
    $this->view->display('hello_view');
  }
}


You do not need to include your extension file, TinyMVC will autoload it so long as it is named internal.classname.php in the plugins directory.

The same procedure applies for extending TinyMVC_Model and TinyMVC_View.


Personal tools