开发者

how to access the configuration data from within a controller action?

开发者 https://www.devze.com 2023-03-05 01:56 出处:网络
I have place this on my app开发者_运维问答lication.ini file: contact.email.address = \"my.mail@bla.org\"

I have place this on my app开发者_运维问答lication.ini file:

contact.email.address = "my.mail@bla.org"
contact.email.name = "Test Name"

Then on my index controller action I have done:

$configOptions = $this->getInvokeArg('bootstrap')->getOptions();
$contactAddress = $configOptions->contact.email.address;
$this->view->contact = $contactAddress;

On my view I have:

var_dump($this->contact); but I'm receiving NULL.

What am I missing ?


In your controller, I think you want:

$configOptions = $this->getInvokeArg('bootstrap')->getOptions();
$contactAddress = $configOptions['contact']['email']['address'];
$this->view->contact = $contactAddress;


You can use:

$configOptions = new Zend_Config($this->getInvokeArg('bootstrap')->getOptions());
$contactAddress = $configOptions->contact.email.address;
$this->view->contact = $contactAddress;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号