[Module Dev] How To Access The Current Module

Hi,

what is the recommended way to access the current module?

From the userGroups module (e.g. in components/UserGroupsIdentity.php), I can see examples like:


Yii::app()->controller->module->profile

for accessing the profile property of the userGroups module.

Unfortunately this failed to me in some situations, so I ended up rewriting it as:


Yii::app()->getModule('userGroups')->profile

that has the disadvantage of explicitly knowing the module name.

I’m wondering how should I access the current module properly…

Thanks in advance, E.