I have a project that uses Zend Framework and Zend_Translate
.
I had to alter the standard CSV Adapter to Zend_Translate slightly. Now I'm confronted with the question where to put this altered adapter.
By default, adapters are stored in
/Library/Zend/Translate/Adapter/Adaptername.php
This is where I've put the new adapter as well.
However, I wouldn't like to "pollute" the Zend library with my custom extensions: I would like to stay able to update ZF without having to worry about losing files; I want to remain able to use a centrally installed version of ZF; and the custom adapter is part of the project I'm working on, really.
Is there a Zend Framework way of dealing with this, or specifying an alternative loading location?
Language adapters are loaded using
$this->_adapter = new $adapter($data, $locale, $options);
(Where $adapter
will be Zend_Translate_Adapter_Adaptername
)
so standard autoloading rules apply. Is there a simple way to tell the Zend Autoloader to look in a second location?
You can add it to the lib folder
/lib
/Zend
/Translate
/Adapter
/Csv.php
/My
/Translate
/Adapter
/Csv.php
Depending on how your autoloader is setup, you have to setup the "namespace" with it:
$autoloader->registerNamespace('My_');
Or, if you dont like this, put it into your models folder. Basically, it doesnt matter where you put it, as long as it is accessible somehow by the autoloader. The Zend_Autoloader
can register arbitrary autoloader callbacks, so it's really up to you.