Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Loaded Config In Controller

How do i get the already loaded options in the controller file in a zend framework installation without creating a new Zend_Config([ ** ]); instance.

like image 774
Brandon_R Avatar asked Aug 24 '10 13:08

Brandon_R


2 Answers

Once Zend_Application reads application.ini, the values are stored in bootstrap.

You may access them anywhere, without accessing the disk, or using the registry:

$front = Zend_Controller_Front::getInstance();
$bootstrap = $front->getParam('bootstrap');
if (null === $bootstrap) {
    throw new My_Exception('Unable to find bootstrap');
}

$options = $bootstrap->getOptions();

In the controller you may also use $this->getInvokeArg('bootstrap');

like image 148
takeshin Avatar answered Oct 05 '22 19:10

takeshin


I am not sure at all what you are asking but are you asking how to use configs set in application.ini from a controller? If so you should load that config in Zend_Registry in your bootstrap and then retrieve it in your controller.

So in bootstrap.php

  protected function _initConfig() {
        $config = new Zend_Config_Ini("../application/configs/application.ini");
        Zend_Registry::set('config', $config);
    }

The in your Controller

  $myConfig = Zend_Registry::get('config');
like image 44
Iznogood Avatar answered Oct 05 '22 19:10

Iznogood