I have my config defined via Zend_Config_Ini adapter, with production, development and testing sections. In my controller I would like to take certain actions depending on what environment/section I am currently using – e.g. I only want to send email in production and testing, not in development.
Is there a way to determine which environment/section I am using the controller? I can set a value in the config and grab that in the controllers, but seems like there would be a cleaner way to determine.
If you put the code that depends on the environment in your controller, like this :
It adds logic in the controller — the sending of the mail doesn’t depend on the configuration anymore.
I think it’s better to add one
mail.enableoption in your configuration files, and use that specific option in your code, to determine whether or not you must send mails.This way :
Of course, it means a couple more configuration entries (one to enable/disable e-mails, one for any other thing that can be enabled or not) ; but, in the end, that’s what configuration is for.