2009年4月28日星期二

Re: [fw-mvc] Question on modules configs - Zend_Application

-- Cristian Bichis <contact@zftutorials.com> wrote
(on Tuesday, 28 April 2009, 09:17 PM +0300):
> I am just wondering if the configuration for modules has been rewrited to be
> modular (config file as /modulename/configs.ini) ?

It has not yet. I'm slating that for a later release in the 1.8 series.

In the meantime, you can always override your bootstrap's constructor to
fetch configuration from your module:

class Blog_Bootstrap extends Zend_Application_Module_Bootstrap
{
public function __construct($application)
{
$configPath = dirname(__FILE__) . '/configs/config.ini';
if (file_exists($configPath)) {
$config = new Zend_Config_ini($configPath, $application->getEnvironment());
$this->setApplication($application)
->setOptions($config->toArray())
->initResourceLoader();
} else {
parent::__construct($application);
}
}
}

> because i am seeing this:
>
> http://framework.zend.com/manual/en/zend.application.available-resources.html
>
> [production]
> news.resources.db.adapter = "pdo_mysql"
> news.resources.db.params.host = "localhost"
> news.resources.db.params.username = "webuser"
> news.resources.db.params.password = "XXXXXXX"
> news.resources.db.params.dbname = "news"
> news.resources.layout.layout = "news.phtml"
>
> Which means modules are not quite so "modular"...
>
> Or is just documentation behind the code ?

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: