Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Bootstrap

linusnorton edited this page Dec 30, 2011 · 2 revisions

It may be necessary to bootstrap your application with certain settings. This can achieved in two ways:

Controller Level Bootstrap

Using a shared controller:

use \xframe\request\Controller;

class MyController extends Controller {

    /**
     * Called before run() and about()
     */ 
    public function init() {
        parent::init();

        $this->view->navigation = array("home", "about", "contact");
    }

    /**
     * @Request("index")
     */
    public function run() {
        
    }

    /**
     * @Request("about")
     */
    public function about() {
        
    }
}

Application Level Bootstrap

Using inheritance:

use \xframe\request\Controller;

class Bootstrap extends Controller {

    /**
     * Called all requests
     */ 
    public function init() {
        parent::init();

        $this->view->navigation = array("home", "about", "contact");
    }
}

class Index extends Bootstrap {

    /**
     * @Request("index")
     */
    public function run() {
        
    }
}

class About extends Bootstrap {

    /**
     * @Request("about")
     */
    public function about() {
        
    }

}    
Clone this wiki locally