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

前端 未结 7 1628
忘掉有多难
忘掉有多难 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条回答
  •  -上瘾入骨i
    2021-01-30 15:05

    In most ZF apps, the application object is declared in the global scope (see public/index.php in apps created with ZFW_DISTRIBUTION/bin/zf.sh).

    It's not exactly the ZF way, but you can access the object with $GLOBALS['application']. It kinda feels like cheating, but if you're after performance, this will likely be the quickest option.

    $manager = new My_Model_Manager($GLOBALS['application']->getOption('my'));
    

提交回复
热议问题