2009年4月23日星期四

[fw-mvc] Zend_Application: autoloadernamespaces in config file

Hi,

I've been using my own application classes with Zend Framework for
now, but for a new app I want to use Zend_Application.

Since I have my own library classes, I had to register a namespace for
the autoloader. I found the function setAutoloaderNamespaces on
Zend_Application. But since I want to do it trough the config, I
decided to set the parameter "setAutoloaderNamespaces".

When I provide the application with an option array on config, this
doesn't present problems since I can provide a nice array as expected.
This is however not the way I want to use this. I think most people
like me provide the path to the ini file and setup everything there.

So, I tried to add following line:

autoloadernamespaces = Amz

But this failed miserably, the reason being that the function that
processes this expects an array and not a string.

What is the syntax in the init file to allow a value to be processed
as array? I tried a comma seperated list with squared brackets
["Zend", "Amz"] but that didn't work either.

Anyone have an idea how this can be done?

If there is no way, a possible fix in Zend_Application would be to
change the following lines in the setOptions call:

if (!empty($options['autoloadernamespaces'])) {
$this->setAutoloaderNamespaces($options['autoloadernamespaces']);
}

To something like:

if (!empty($options['autoloadernamespaces'])) {
$namespaces = explode(',', $options['autoloadernamespaces']),
$this->setAutoloaderNamespaces($namespaces);
}

so to summarize:

1/ anyone know how to do it using the ini config file without having
to extend the Zend_Application class?

2/ ifit's not possible, could a fix for this been implemented?

Wkr
Jeroen K

没有评论: