Implémentation des actionStack
Bon,
voilà, j'ai suivi le tuto de julien Pauli, mais j'ai des erreurs lors du rendu.
Je suppose avoir raté quelque-chose, mais je trouve pas quoi.
voici donc mon Bootstrap :
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
| <?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected $_config;
protected function _initConfig()
{
// config
$this->_config = new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini', APPLICATION_ENV);
Zend_Registry::set('config', $this->_config);
Zend_Registry::set('env', APPLICATION_ENV);
// debugging
if($this->_config->debug) {
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 'on');
}
}
protected function _initDB()
{
// Database
if($this->_config->db) {
$dbAdapter = Zend_Db::factory($this->_config->db);
Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
Zend_Registry::set('dbAdapter', $dbAdapter);
}
}
protected function _initView()
{
// view and layout setup
Zend_Layout::startMvc(APPLICATION_PATH . '/views/layouts');
$view = Zend_Layout::getMvcInstance()->getView();
$view->doctype('XHTML1_STRICT');
$view->headTitle($this->_config->title)->setSeparator(' - ');
$view->headLink()->appendStylesheet('/_css/blueprint/screen.css','screen,projection');
$view->headLink()->appendStylesheet('/_css/blueprint/print.css','print');
$view->headLink()->appendStylesheet('/_css/blueprint/ie.css','screen,projection','IE');
$view->headMeta()->appendHttpEquiv('Content-Type','text/html; charset=utf-8');
}
protected function _initFrontController()
{
$frontController = Zend_Controller_Front::getInstance();
$frontController->setControllerDirectory(APPLICATION_PATH .'/controllers');
$frontController->setParam('env', APPLICATION_ENV);
$frontController->setParam('config',$this->_config);
// action helpers
Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH .'/controllers/helpers');
$actionStack = Zend_Controller_Action_HelperBroker::getStaticHelper('actionStack');
$actionStack->actionToStack('footer','index');
$actionStack->actionToStack('header','index');
}
public function run()
{
$frontController = Zend_Controller_Front::getInstance();
$frontController->dispatch();
}
} |
voici mon IndexController :
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
| <?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// action body
}
public function headerAction($request)
{
//$this->view->text = 'tyty';
$this->_helper->viewRenderer->setResponseSegment('header');
}
public function footerAction($request)
{
//$this->view->text = 'footer';
$this->_helper->viewRenderer->setResponseSegment('footer');
}
} |
et mon layout :
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
| <?php echo $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?=$this->headTitle() ?>
<?=$this->headMeta() ?>
<?=$this->headLink() ?>
<?=$this->headStyle() ?>
<?=$this->headScript() ?>
</head>
<body>
<div class="container">
<div id="header" style="background-color: #EEEEEE; height: 30px;">
<?php
echo $this->layout()->header;
?>
</div>
<div>
<?=$this->layout()->content ?>
</div>
<div>
<?php
echo $this->layout()->footer;
?>
</div>
</div>
</body>
</html> |
et voici l'erreur que j'ai :
Citation:
Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'Request object not set yet' in /Users/guillaume/Sites/mycompte/library/Zend/Controller/Action/Helper/ActionStack.php:108 Stack trace: #0 /Users/guillaume/Sites/mycompte/application/Bootstrap.php(55): Zend_Controller_Action_Helper_ActionStack->actionToStack('footer', 'index') #1 /Users/guillaume/Sites/mycompte/library/Zend/Application/Bootstrap/BootstrapAbstract.php(660): Bootstrap->_initFrontController() #2 /Users/guillaume/Sites/mycompte/library/Zend/Application/Bootstrap/BootstrapAbstract.php(613): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('frontcontroller') #3 /Users/guillaume/Sites/mycompte/library/Zend/Application/Bootstrap/BootstrapAbstract.php(577): Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap(NULL) #4 /Users/guillaume/Sites/mycompte/library/Zend/Application.php(324): Zend_Application_Bootstrap_BootstrapAbstract->bootstrap() #5 /Users/guillaume/Sites/mycompte/public/index.php(25): Zend_Application->boot in /Users/guillaume/Sites/mycompte/library/Zend/Controller/Action/Helper/ActionStack.php on line 108
voyez vous t'où ça peu venir ? moi ça fais deux jour que j'essaye plein de truc mais rien a faire.