I cannot seem to find an official information about what is the recommended way to retrieve configuration values in Magento 2.
I am searching for the recommended way to retrieve values from the configuration. Should it be from a Helper, or from a “Config” Model ?
In the Magento official documentation about best practices, they talk about avoiding to create helper classes, but it is more about static methods.
In the Magento code, we can see both are used, and even sometimes the config values are retrieved directly from other classes along with other code logic.
Here are some examples of both usages :
- Data Helpers :
- Config Models :
What is your approach on this matter ? And why ?
I will share my own approach about it, and am open to comments to discuss about it.