Archived
1
0
Fork 0

Bootstrap: Navigation,Router,View/Layout,Config

This commit is contained in:
Fredric N 2010-08-21 19:51:35 +02:00
parent 14375db575
commit fe10b02c33
4 changed files with 103 additions and 16 deletions

View file

@ -5,22 +5,56 @@
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Setup view object
* Setup navigaion
*
* return Zend_View $view
* @return Zend_Navigation $navigation
*/
protected function _initNav()
{
// Make sure we have our layout setup first.
$this->bootstrap('view');
$navConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'navigation');
$navigation = new Zend_Navigation($navConfig);
$view = $this->getResource('view');
$view->navigation($navigation);
return $navigation;
}
protected function _initConfig()
{
return new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
}
/**
* View and Layout configuration
*
* @return Zend_View $view
*/
protected function _initView()
{
// We really should add something here ?
$this->bootstrap('config');
$view = new Zend_View();
$view->setEncoding('UTF-8');
// Set site title
$view->headTitle($this->getResource('config')->app->name);
$layout = Zend_Layout::startMvc();
$layout->setLayoutPath(APPLICATION_PATH . '/modules/default/views/layout');
$layout->setLayout('default');
$layout->setView($view);
return $view;
}
/**
* Configure the front controller
*
* @return Zend_Controller_Front $frontController
*/
protected function _initFront()
{
@ -30,11 +64,41 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
// Set modules directory
$frontController->addModuleDirectory(APPLICATION_PATH . '/modules');
return $frontController;
}
/**
* Configure routes for our application
*
* @return Zend_Controller_Router_Rewrite $router
*/
protected function _initRouter()
{
// Make sure the front controller is ready
$this->bootstrap('front');
$router = $this->getResource('front')->getRouter();
$route = new Zend_Controller_Router_Route(
':lang/:module/:controller/:action/*',
array(
'lang' => 'sv',
'module' => 'default',
'controller' => 'index',
'action' => 'index'
)
);
$router->addRoute('default', $route);
return $router;
}
/**
* Setup a sweet and simple database
* connection
* connection.
*
* @return
*/
protected function _initDatabase()
{