phpyiiyii2yii-modules

Yii2: uniqueID and id modules properties


Class yii\base\Module has 2 properties: id and uniqueId. The former "uniquely identifies this module among other modules which have the same parent", while the latter - just unique id. But I still don't understand the diff. Why need we id to identify module, especially from modules with the same parent, if there is uniqueId, that identifies module too? It would be nice to show me example, which reveals the need for both these properies.


Solution

  • The module id is the relative ID of a module and when there aren't parent the module id coincides with the uniqueId. but if you use nested module (one or more) within other then comes the need to be able to still assign an identifier of the module (his name). This name is assigned using Id, which corresponds to the entry in config/main.php. The need to manage, as part of the framework, the absolute identification of each of these nested modules is instead carried out by UniqueId. UniqueId is read only because his correct construction is managed by the Framework