What is the preferred approach to supply constant values to a View Helper? If a view helper requires configuration constants. For example, a google api key or amazon web services access keys, is it best to:
A) Make the developer put these values in a Zend_Config object and then access the config object in the View Helper's constructor? B) Make the developer assign the values as view variables and access them with $this->view->var inside the view helper? C) Pass the variables to the view helper when it is called in the view script? I am not a fan of any of these choices, but if I had to pick one I'd go with A. I like the fact that A centralizes the constants in a relatively secure spot. They would be sitting next to database passwords, etc. But I don't like the constraints it places on the developer. Not only would Zend_Config need to be used, but the config object would either need to be stored in a registry, or created inside the view helper. Even if I create the Zend_Config object inside the view helper, I would still need to pass the constant params needed for Zend_Config... I don't like the idea of adding what could be sensitive information, the aws private key for example, to the view object, so that eliminates B and C. I think C is the worst of all because it adds an extra var to supply when calling the view helper. What other options are there if any? What would be acceptable dependencies for a Zend_View_Helper? To make things slightly more complicated, I guess there is the possibility that these "constant" values could change during the life of a single request or on a page by page basis, thus they would no longer be constant. This could happen if someone uses two or more AWS accounts for example. This could be dealt with, but would add complexity. I want to make decisions that result in the most flexible and easy to use view_helper possible. I am working on a Zend_View_Helper proposal http://framework.zend.com/wiki/display/ZFPROP/Zend_View_Helper_S3Link+-+Jason+DeBordand I think this is the only issue holding up the completion of the prototype code. The view helper I created to accomplish what is outlined in my proposal uses a Zend_Config object stored in Zend_Registry. While this works great and might be fine for my colleagues purposes, I am not sure it is a viable solution for a Zend Framework component. Thanks a lot, Jason
