Move gii application components to beforeAction

GiiModule should only adjust environment when it actually runs a
controller action. It should not affect app in other cases.

see issue #1906 for details