Module Frontend par défaut avec préfixe
Bonjour,
j'utilise les modules, j'ai donc modifié mon Bootstrap et mon archtecture pour avoir un module Frontend et un module Backend.
Extrait de mon application/Bootstrap.php
Code:
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 85 86 87 88
| class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
public function run()
{
try {
// Instancie le contrôleur frontal
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(false);
$frontController->setDefaultModule("Frontend");
$frontController->setControllerDirectory(array(
'Frontend' => APPLICATION_PATH .'/modules/frontend/controllers',
'Backend' => APPLICATION_PATH .'/modules/backend/controllers'
));
// Cela permet d'avoir le fichier de configuration disponible depuis n'importe ou dans l'application.
Zend_Registry::set('config', new Zend_Config($this->getOptions()));
parent::run();
} catch (Zend_Controller_Exception $e) {
//var_dump($e);
exit($e->getMessage());
include 'errors/404.phtml';
} catch (Exception $e) {
exit($e->getMessage());
include 'errors/500.phtml';
}
}
protected function _initDb()
{
//on charge notre fichier de configuration
$config = new Zend_Config($this->getOptions());
//On essaye de faire une connection a la base de donnee.
try{
$db = Zend_Db::factory($config->resources->db);
//on test si la connection se fait
$db->getConnection();
Zend_Db_Table::setDefaultAdapter($db);
}catch ( Exception $e ) {
exit( $e -> getMessage() );
}
// on stock notre dbAdapter dans le registre
Zend_Registry::set( 'dba', $db );
return $db;
}
protected function _initDefaultNamespace()
{
$moduleLoaders = array();
// Frontend
$frontend = new Zend_Application_Module_Autoloader(
array(
'namespace' => 'Frontend_',
'basePath' => APPLICATION_PATH . '/modules/frontend',
)
);
// Backend
$backend = new Zend_Application_Module_Autoloader(
array(
'namespace' => 'Backend_',
'basePath' => APPLICATION_PATH . '/modules/backend',
)
);
$moduleLoaders['Frontend'] = $frontend;
$moduleLoaders['Backend'] = $backend;
return $moduleLoaders;
} |
Par contre je ne comprend pas pourquoi je ne peux pas appeler mes controllers Frontend_IndexController, Frontend_ErrorController, etc.. mais seulement IndexController, etc...
Sinon j'ai une exception "IndexController introuvable".