呃,我對應用程序瞭解不多,但在我看來,它並不是一個Bootstrap對象。看着我的轉儲,似乎Zend_Application實際上與它相關聯。它似乎也有您正在尋找的細節:
object(Bootstrap)[3]
protected '_appNamespace' => string '' (length=0)
protected '_resourceLoader' =>
object(Zend_Application_Module_Autoloader)[7]
protected '_application' =>
object(Zend_Application)[1]
protected '_classResources' =>
protected '_container' =>
object(Zend_Registry)[15]
protected '_environment' => null
protected '_optionKeys' =>
array
protected '_options' =>
array
'phpSettings' =>
array
'display_startup_errors' => string '1' (length=1)
'display_errors' => string '1' (length=1)
'date' =>
array
...
'bootstrap' =>
array
'path' => string 'C:\sites\mysite\application/Bootstrap.php' (length=39)
'class' => string 'Bootstrap' (length=9)
'resources' =>
array
'frontController' =>
array
...
'modules' =>
array
...
'layout' =>
array
...
'view' =>
array
...
'session' =>
array
...
'log' =>
array
...
'doctrine' =>
array
...
'appnamespace' => string '' (length=0)
'autoloadernamespaces' =>
protected '_pluginLoader' =>
object(Zend_Loader_PluginLoader)[35]
其實我不知道爲什麼你有問題,你將不得不給我們一些轉儲。
它工作時,我嘗試:
<?php
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
protected function _initApp()
{
$app = $this->getApplication();
echo '1:';
// die(var_dump($app->getOptions()));
var_dump($app->getOption('phpSettings'));
$app->setOptions(array('phpSettings'=>array('date'=>array('timezone'=>'America/New York'))));
echo '2:';
var_dump($app->getOption('phpSettings'));
}
}
這是我的佈局:
<?php
echo 'in layout';
$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
var_dump($bootstrap->getOptions());
?>
這是我的輸出:
1:
array
'display_startup_errors' => string '1' (length=1)
'display_errors' => string '1' (length=1)
'date' =>
array
'timezone' => string 'Africa/Johannesburg' (length=19)
2:
array
'display_startup_errors' => string '1' (length=1)
'display_errors' => string '1' (length=1)
'date' =>
array
'timezone' => string 'America/New York' (length=16)
in layout
array
'phpSettings' =>
array
'display_startup_errors' => string '1' (length=1)
'display_errors' => string '1' (length=1)
'date' =>
array
'timezone' => string 'America/New York' (length=16)
工作正常,我。
在我的應用程序/引導程序中,我可以正確地獲得$ this-> getAPplication()。 PHP設置生效。而在應用程序/模塊/ module5/Bootstrap.php Im我鬆散的應用程序對象,getApplication()返回Bootstrap而什麼也不做,PHP設置不會被激活。 – thevikas 2011-05-12 02:47:55