-
Notifications
You must be signed in to change notification settings - Fork 12
add support for custom template file default suffix #64
Conversation
I do not like much that configuration for the resolver needs to be added to template renderer like that. It feels out of place here tbh. I have no other suggestions at this point however. |
Hello @Xerkus
I added the config entry for completeness, but it can be omitted because the default template resolver's suffix is 'phtml'. If a config entry exists, that will be injected into the resolver. Maybe we could comment out that entry with a clarifying note. kind regards |
@pine3ree let me clarify: The fact that you had to modify template renderer to add functionality, the configuration of dependency, that is not related to template renderer responsibilities is a violation of Separation of Concern principle. Dependency is internal detail as long as you do not need external input for it, which makes it conditionally acceptable. Unit testing usually is a first place where the problem is exposed, when you need to provide alternative implementation for testing purposes. The proper solution here is to remove dependency setup from template renderer and do that in a factory. That would, however, constitute a Backward Compatibility break so it would need a major version release to happen. Now why it was done like that in the first place? Convenience of use was overriding factor when this code was initially implemented, it needed to just work and we had no convenient way to provide and configure container factories. It was before zend-config-aggregator component to consume ConfigProviders, zend-component-installer component to auto-inject ConfigProviders and config adapters for various container implementations. So my dislike of the situation is just that: a dislike. I considered other possible approaches and your offers the least impact on the future compatibility with the next major release. That makes it the best we could do right now. |
Hello @Xerkus,
If you are referring to zend-expressive ZendViewRenderer, in my opinion it is not just a template "renderer" but an implementation of a very simple interface acting as a bridge to a whole package. zend-view in this case....well... parts of it. zend-expressive template renderer interface has 4 methods:
so the interface itself tells us that ii is not just a "pure renderer" interface Internally zend-expressive-zendviewrenderer creates the zend-view (php-)renderer, the resolver, the view model and allows to add search paths...and more...so adding a configuration parameter in the constructor only exploits what it is already doing....i.e. ... quite a lot....no much separation of concerns...the separation of concerns is implemented in the package it refers to! kind regards, |
@pine3ree nothing in this repository provides interoperability contract. So, anything that goes beyond what is established by I am going to provide a patch soon-ish that would resolve my concerns for the next major. You can ping me in zendframework slack and we can discuss this in detail if you like. |
@Xerkus, |
PR for: zendframework/zend-expressive#641
I wonder if we should use the same configuration key in all compatible implementations (platesrenderer already support custom suffix with the
extension
config key)