Archived
1
0
Fork 0
This repository has been archived on 2026-05-10. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
fiktivkod/application/Bootstrap.php
2010-08-21 21:10:21 +02:00

155 lines
No EOL
3.8 KiB
PHP

<?php
/**
* Bootstrap this shit
*/
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Setup navigaion
*
* @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;
}
/**
* View and Layout configuration
*
* @return Zend_View $view
*/
protected function _initView()
{
$view = new Zend_View();
$view->setEncoding('UTF-8');
// Set site title from application.ini
$config = $this->getApplication()->getOptions();
$view->headTitle($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()
{
$this->bootstrap('autoloader');
// Get front controller
$frontController = Zend_Controller_Front::getInstance();
// Set modules directory
$frontController->addModuleDirectory(APPLICATION_PATH . '/modules');
// Add plugins
$frontController->registerPlugin(new Fiktiv_Controller_Plugin_Language());
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;
}
/**
* Configure global and local(modules) models
*/
protected function _initModels()
{
$this->bootstrap('autoloader');
// Include global model directory
set_include_path(implode(PATH_SEPARATOR, array(
APPLICATION_PATH . '/models',
get_include_path()
)));
// Let our model autoloader plugin handle local models
$front = $this->getResource('front');
$front->registerPlugin(new Fiktiv_Controller_Plugin_ModelAutoloader());
}
/**
* Configure autoloader
*
* @return Zend_Loader_Autoloader $autoloader
*/
protected function _initAutoloader()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Fiktiv_');
$autoloader->setFallbackAutoloader(true);
return $autoloader;
}
/**
* Configure multilanguage (translator)
*
* @return Zend_Translate $translate
*/
protected function _initTranslate()
{
$translate = new Zend_Translate('ini', APPLICATION_PATH . '/languages/se.ini', 'sv');
$translate->addTranslation(APPLICATION_PATH . '/languages/en.ini', 'en');
Zend_Form::setDefaultTranslator($translate);
return $translate;
}
/**
* Setup a sweet and simple database
* connection.
*
* @return
*/
protected function _initDatabase()
{
// Oh, my!
}
}