-
Notifications
You must be signed in to change notification settings - Fork 2.5k
TemplateWrapper getter #6679
TemplateWrapper getter #6679
Conversation
Added the call of getTemplateWrapper() instead of directly passing the protected var.
No, it's already right. We call it in same class |
For consistency I agree with @backnight. If you look at the class as a whole almost everywhere the getters are used. Personally I prefer using the getters whenever they are available. Perhaps this is something for the ZF2 coding standards? |
using getter is only make sense when working from outside class, and it faster too, except getter do logic rather than only return the value. you can take a look at Zend\Mvc\Application.php that I replaced the getter with call directly the properties. Warm regards, Abdul Malik Ikhsan Pada 22 Sep 2014, pukul 14.25, Martin-P notifications@github.com menulis:
|
That is the main reason for me to use getters whenever they are available, you never know if you need to add some logic to a getter. IMHO the ease of code change when using getters whenever they are available supersedes the minor performance gain (benchmark?) for directly accessing properties. In this case getters are already available and therefore it seems logical to me to use them. |
I added the getter because I needed to do some logic.
class BaseCollection extends FormCollection
} The templateWrapper is not just an html element containing the template, I use it also to add the template to the collection, like a button. Zend is not using the getter, so the translation is not occurring that why I added the call of the getter instead of the var directly. |
at that case, I personally override the |
The $templateWrapper var should be kept as a template (with "%s"). It's easier for further logics and reading.
|
I'm fine with the introduced change, as it allows for easier overrides, but I'd still ask for a test case validating the call. This may be done by mocking the SUT and replacing the getter at runtime. |
Will merge as-is: can't spend time testing this via reflection ATM, and it would be a minor BC break to change this afterwards anyway, so it doesn't need to be protected against regressions. |
…instead-of-direct-property-access' into develop Close #6679
Merged, thanks @backnight:
|
Added the call of getTemplateWrapper() instead of directly passing the protected var.