i am trying to figure out how to achieve something like a plugin architecture for my zend framework application.
Let’s say i have a upload formular for some documents. If there is no “plugin” i want to have some default uploads to my webserver. However if i do insert my “specific-upload-plugin” i want the files to be uploaded to sharepoint (just as an example).
But i really want to achieve this without changing much code at all. I would be fine with changing some config file but i shouldnt need to change any controller code at all.
Can someone point me out some tutorials or methods on how i will be able to achieve that? Or just some best practices on that kind of task?
Thank you in advance
My first thought is to extend
Zend_File_Transfer_Adapter_Httpwhich is the adapter that is used for handling a standardFileupload element in Zend Framework.All you may need to do is overload the
receive()method to receive the file but instead of moving the file to a permanent location on the server, you could have your adapter upload to sharepoint, or take care of moving the file to the final destination wherever it may be.Your constructor could set adapter specific options such as sharepoint IP address and credentials and any other options you need.
This way, no changes need to be made to the controller, you would simply modify your
Zend_Formobject to use aFileelement but give it your custom transfer adapter. All validation and error handling is done by Zend_Form, and your adapter takes care of the details of putting the file where it needs to go and any errors encountered there can be passed back to the form. Therefore, there is no need to change any controller code; all that logic lives in your transfer adapter and form.Hope that helps point you in the right direction.