In order to pave the way for REST API support, the view layer needs to support rendering DAOs as JSON or XML as well as HTML. To achieve this, all code that outputs HTML in the AlphaView class will be moved to a new HTML renderer implementation, which will then be injected at runtime using a dependency injection mechanism.
Here are some possible renderering modes to support (for this ticket we will just do HTML):
- Mobile HTML
- Everything is a DAO.
- Renderer for DAO injected, based on 3 possible scenarios: AlphaView::setRenderer('ImplementationClassName'), config property (force a given renderer, default value is "auto"), or finally auto-detection via content negotiation (see note on this here: http://www.design-ireland.net/article/Adding_a_REST_API_to_the_Alpha_Framework).
- Renderers should be well structured (define a standard public interface).
- Renderers should be extendable (custom DAOs may continue to have their own views and templates, as well as callbacks).
- Renderers should implement a file cache (just like HTML cache now), make this part of the interface.
Proposed folder structure:
And at the application level:
edit.phtml // custom template overrides go here as before with Alpha 1.1
header.phtml // this will override global HTML header with a custom one