How can I access the configuration of a Zend Framework application from a controller?

前端 未结 7 1629
忘掉有多难
忘掉有多难 2021-01-30 14:18

I have a Zend Framework application based on the quick-start setup.

I\'ve gotten the demos working and am now at the point of instantiating a new model class to do some

相关标签:
7条回答
  • 2021-01-30 15:16

    I've define a short hand in some place I require_once() in the beginning of boostrap:

    function reg($name, $value=null) {
        (null===$value) || Zend_Registry::set($name, $value);
        return Zend_Registry::get($name);
    }
    

    and in the bootstrap I have a:

    protected function _initFinal()
    {
        reg('::app', $this->getApplication());
    }
    

    then I can get the Application instance anywhere by use:

    $app = reg('::app');
    
    0 讨论(0)
提交回复
热议问题