* :-)
[sport-group.git] / application / bootstrap.php
blob077fe3c1a702f9b7ef6d7054a3996f0fed22f2bf
1 <?php
2 // application/bootstrap.php
3 // Step 1: APPLICATION CONSTANTS - Set the constants to use in this application.
4 // These constants are accessible throughout the application, even in ini
5 // files. We optionally set APPLICATION_PATH here in case our entry point
6 // isn't index.php (e.g., if required from our test suite or a script).
7 defined('APPLICATION_PATH')
8 or define('APPLICATION_PATH', dirname(__FILE__));
10 defined('APPLICATION_ENVIRONMENT')
11 or define('APPLICATION_ENVIRONMENT', 'development');
14 // CONFIGURATION - Setup the configuration object
15 // The Zend_Config_Ini component will parse the ini file, and resolve all of
16 // the values for the given section. Here we will be using the section name
17 // that corresponds to the APP's Environment
18 $configuration = new Zend_Config_Ini(
19 APPLICATION_PATH . '/config/app.ini',
20 APPLICATION_ENVIRONMENT
23 // Step 2: FRONT CONTROLLER - Get the front controller.
24 // The Zend_Front_Controller class implements the Singleton pattern, which is a
25 // design pattern used to ensure there is only one instance of
26 // Zend_Front_Controller created on each request.
27 $frontController = Zend_Controller_Front::getInstance();
29 // Step 3: CONTROLLER DIRECTORY SETUP - Point the front controller to your action
30 // controller directory.
31 $frontController->setControllerDirectory(APPLICATION_PATH . '/controllers');
33 // Step 4: APPLICATION ENVIRONMENT - Set the current environment.
34 // Set a variable in the front controller indicating the current environment --
35 // commonly one of development, staging, testing, production, but wholly
36 // dependent on your organization's and/or site's needs.
37 $frontController->setParam('env', APPLICATION_ENVIRONMENT);
39 // LAYOUT SETUP - Setup the layout component
40 // The Zend_Layout component implements a composite (or two-step-view) pattern
41 // With this call we are telling the component where to find the layouts scripts.
42 Zend_Layout::startMvc(APPLICATION_PATH . '/layouts/scripts');
44 // VIEW SETUP - Initialize properties of the view object
45 // The Zend_View component is used for rendering views. Here, we grab a "global"
46 // view instance from the layout object, and specify the doctype we wish to
47 // use. In this case, XHTML1 Strict.
48 $view = Zend_Layout::getMvcInstance()->getView();
49 $view->doctype('XHTML1_STRICT');
50 #$view->addHelperPath(APPLICATION_PATH . '/../library/ZendX/JQuery/View/Helper',
51 # 'ZendX_JQuery_View_Helper');
54 // DATABASE ADAPTER - Setup the database adapter
55 // Zend_Db implements a factory interface that allows developers to pass in an
56 // adapter name and some parameters that will create an appropriate database
57 // adapter object. In this instance, we will be using the values found in the
58 // "database" section of the configuration obj.
59 $dbAdapter = Zend_Db::factory($configuration->database);
61 // DATABASE TABLE SETUP - Setup the Database Table Adapter
62 // Since our application will be utilizing the Zend_Db_Table component, we need
63 // to give it a default adapter that all table objects will be able to utilize
64 // when sending queries to the db.
65 Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
67 // REGISTRY - setup the application registry
68 // An application registry allows the application to store application
69 // necessary objects into a safe and consistent (non global) place for future
70 // retrieval. This allows the application to ensure that regardless of what
71 // happends in the global scope, the registry will contain the objects it
72 // needs.
73 $registry = Zend_Registry::getInstance();
74 $registry->configuration = $configuration;
75 $registry->dbAdapter = $dbAdapter;
77 $auth = Zend_Auth::getInstance();
79 $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);
80 $authAdapter->setTableName('player')
81 ->setIdentityColumn('login')
82 ->setCredentialColumn('passwd');
83 #Zend_Registry::set('authAdapter', $authAdapter);
84 #$auth->setStorage(new Zend_Auth_Storage_Session('user'));
87 // LOCALE SETUP
88 $locale = new Zend_Locale('cs_cz');
89 Zend_Registry::set('Zend_Locale', $locale);
91 // Step 5: CLEANUP - Remove items from global scope.
92 // This will clear all our local boostrap variables from the global scope of
93 // this script (and any scripts that called bootstrap). This will enforce
94 // object retrieval through the applications's registry.
95 unset($frontController, $view, $configuration, $dbAdapter, $registry, $locale, $auth, $authAdapter);