Bootstrap
[ class tree: Bootstrap ] [ index: Bootstrap ] [ all elements ]

Source for file Application.php

Documentation is available at Application.php

  1. <?php
  2. /**
  3.  * Application_Bootstrap_Application
  4.  * 
  5.  * Copyright (C) 2009  Mai (Me Artificial Intelligence)
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation, either version 3 of the License, or
  10.  * (at your option) any later version.
  11.  *
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  * 
  20.  * @author Wouter Bulten (wouterbulten@mai-ai.org)
  21.  * @copyright Copyright (C) 2009  Mai (Me Artificial Intelligence)
  22.  * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
  23.  * @link http://www.launchpad.net/mai
  24.  * 
  25.  * @package Bootstrap
  26.  * @subpackage Application
  27.  * 
  28.  */
  29.  
  30. /**
  31.  * Application_Bootstrap_Application is the bootstrap for the application.
  32.  * 
  33.  * @author Wouter Bulten (wouterbulten@mai-ai.org)
  34.  * @copyright Copyright (C) 2009  Mai (Me Artificial Intelligence)
  35.  * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
  36.  * @link http://www.launchpad.net/mai
  37.  * 
  38.  * @package Bootstrap
  39.  * @subpackage Application
  40.  * 
  41.  *  
  42.  */
  43. {
  44.     /**
  45.      * Private constructor to prevent creation of this object.
  46.      * @return void 
  47.      */
  48.     private function __construct(){}
  49.      
  50.     /**
  51.      * Starts up the bootstrap.
  52.      * @return void 
  53.      */
  54.     static public function run()
  55.     {
  56.         //Set include paths
  57.         parent::initIncludePaths();
  58.         //Start auto loader
  59.         parent::initAutoLoader();
  60.         //Load global config
  61.         parent::initGlobalConfig();
  62.  
  63.         //Init base db connection
  64.         parent::initBaseDbConnection(parent::returnDbConfig());
  65.         //Init user db connection
  66.         parent::initUserDbConnection(parent::returnDbConfig());
  67.  
  68.         //Configure Doctrine
  69.         //@Mai Todo: Move this to a seperate function inside Application_Bootstrap_Base
  70.         Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDEtrue);
  71.         
  72.         //Init frontcontroller
  73.         self::initFrontController();
  74.         
  75.         //Dispatch the application
  76.         Zend_Controller_Front::getInstance()->dispatch();
  77.     }
  78.     
  79.     /**
  80.      * Configure the frontController.
  81.      * @return void 
  82.      */
  83.     static private function initFrontController()
  84.     {
  85.         //Get the frontcontroller
  86.         $frontController Zend_Controller_Front::getInstance();
  87.         
  88.         //Set modules
  89.         $frontController->setControllerDirectory(array(
  90.             'default'        =>    APPLICATION_PATH '/modules/default/controllers',
  91.         ));
  92.         $frontController->setDefaultModule('default');
  93.         
  94.         //Define plugin cache file
  95.         //Creates an file with require_once statements for faster plugin loading.
  96.         $classFileIncCache BASE_PATH .  '/cache/plugins/pluginLoaderCache.php';
  97.         if(file_exists($classFileIncCache))
  98.         {
  99.             include_once $classFileIncCache;
  100.         }
  101.         Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
  102.         
  103.         //Show errors when in development
  104.         if(Zend_Registry::get('config')->application->development)
  105.         {
  106.             $frontController->throwExceptions(true);
  107.         }
  108.         
  109.         //Register plugins
  110.         self::registerFrontControllerPlugins($frontController);        
  111.     }
  112.     
  113.     /**
  114.      * Register the frontController plugins.
  115.      * @param Zend_Controller_Front $frontController 
  116.      * @return void 
  117.      */
  118.     static private function registerFrontControllerPlugins(Zend_Controller_Front $frontController)
  119.     {
  120.         //Register plugins
  121.     }
  122. }

Documentation generated on Mon, 27 Jul 2009 19:51:46 +0200 by phpDocumentor 1.4.1