Skip to content
LaCodon edited this page Dec 15, 2015 · 2 revisions

Contents

Controller Template

Every Controller has to directly or indirectly extend Famework\Controller\Famework_Controller and implement a init() method.

<?php

use Famework\Controller\Famework_Controller;

class IndexController extends Famework_Controller {

    public function init() {
        $this->_paramHandler = new Paramhandler();
    }

    // put actions here

}

Save paths and naming conventions

Every Controller script has to be named accoring to the following rules:

  1. First letter uppercase + some lower case chars + "Controller.php"
    e.g.: IndexController.php or LoginController.php
  2. The class name has to be equals to the filename
    e.g.: IndexController or LoginController

It is possible to save the Controller script wherever you want but keep in mind that every controller has to be required or autoloaded somewhere in your project. The best place to do this is your /index.php

"404 Not found" Controller

Actually, a default 404 page is automatically rendered if a Controller or Action was not found but it is possible to customize this default page within the IndexController. Just insert this method:

...
class IndexController extends Famework_Controller {
    ...
    public function notfoundAction() {
        $this->_view->turnLayoutOff();
    }
    ...
}

See Famework_View for more information about turnLayoutOff().

Famework_Controller class

{abstract}

Attributes

# $_view: Famework_View

Methods

+ init(): void