1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| <?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAppAutoload()
{
$moduleLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH));
}
protected function _initDoctrine()
{
/* On met Doctrine en autoload */
$this->getApplication()
->getAutoloader()
->pushAutoloader ( array ('Doctrine', 'autoload' ) );
spl_autoload_register(array('Doctrine', 'modelsAutoload'));
/* On récupère une instance de Doctrine */
$manager = Doctrine_Manager::getInstance ();
/* Permet de valider automatiquement l'intégrité des données
** ce qui veut dire que l'on ne peut pas mettre une variable de type string
** dans un champs de type int.
*/
$manager->setAttribute (Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
/* AUTO_ACCESSOR_OVERRIDE va nous permettre de personnaliser l'assignation de données. */
$manager->setAttribute ( Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true );
/* Doctrine permet de personnaliser également les classes de table en permettant
** de créer des méthodes propres à une table.
**
** Ce paramètre permet de charger le fichier contenant nos méthodes personnalisées.
*/
$manager->setAttribute (
Doctrine::ATTR_MODEL_LOADING,
Doctrine::MODEL_LOADING_CONSERVATIVE
);
/* On permet le chargement des classes de table. */
$manager->setAttribute ( Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true );
$doctrineConfig = $this->getOption('doctrine');
Doctrine::loadModels($doctrineConfig['models_path']);
$conn = Doctrine_Manager::connection($doctrineConfig['dsn'],'doctrine');
$conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM,true);
$conn->setCharset('utf8');
$conn->setCollate('utf8_general_ci');
return ($conn);
}
protected function _initNamSpaces()
{
// a verifier c moi ki la rajouté !!!
$autoLoader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Doctrine_');
$autoloader->registerNamespace('Doctrine');
}
} |
Partager