Couldn't the "module" property be moved (from CController) to the new "Component" class?
Also: What about having a central topic for small things, like this one?
Page 1 of 1
module property to Component class
#1
Posted 10 March 2012 - 02:32 AM
Rodrigo Coelho
Check my extension
giix: a code generator for Yii.
The complete beginner's study guide for the Yii Framework
Check my extension
giix: a code generator for Yii.

The complete beginner's study guide for the Yii Framework
#3
Posted 10 March 2012 - 01:17 PM
Currently, only CController has a getModule method (which creates a "module" property), pointing to the module it belongs to.
Since a module is an application inside an application, any component (extends CComponent) can reside in a module.
The proposal is to have a getModule method in the new Component class (which will replace the current CComponent class).
This will help make modules more pluggable/reusable when module's components need to reference its parent module.
--
A lesser alternative to having getModule in Component is to have it in BaseController or to add it to Widget.
Since a module is an application inside an application, any component (extends CComponent) can reside in a module.
The proposal is to have a getModule method in the new Component class (which will replace the current CComponent class).
This will help make modules more pluggable/reusable when module's components need to reference its parent module.
--
A lesser alternative to having getModule in Component is to have it in BaseController or to add it to Widget.
Rodrigo Coelho
Check my extension
giix: a code generator for Yii.
The complete beginner's study guide for the Yii Framework
Check my extension
giix: a code generator for Yii.

The complete beginner's study guide for the Yii Framework
#4
Posted 12 March 2012 - 10:26 AM
But how does the component know which module it belongs to? This is simple in the case of controllers, because they are created exclusively by modules, so the module can pass itself as a parameter to the controller's constructor.
#5
Posted 12 March 2012 - 03:42 PM
phpnode, on 12 March 2012 - 10:26 AM, said:
But how does the component know which module it belongs to?
I was thinking about it while writing the original post. I don't have the answer, but this may be easier the way Yii 2.0 is being designed (which I don't know) or if considered early enough, can be part of the design itself.
Rodrigo Coelho
Check my extension
giix: a code generator for Yii.
The complete beginner's study guide for the Yii Framework
Check my extension
giix: a code generator for Yii.

The complete beginner's study guide for the Yii Framework
#6
Posted 12 March 2012 - 05:30 PM
I don't think it's possible to do this in both a practical and performant way, also I'm not really sure what benefit it brings. Widgets from one module can be used by another module, so what should getModule() return?
#7
Posted 12 March 2012 - 06:11 PM
Good points.
When the idea came, it was to have the method return the module the component (a widget in this case) belongs to, not the module that's using the component. But it might just fit one use case and not fit other ones.
When the idea came, it was to have the method return the module the component (a widget in this case) belongs to, not the module that's using the component. But it might just fit one use case and not fit other ones.
Rodrigo Coelho
Check my extension
giix: a code generator for Yii.
The complete beginner's study guide for the Yii Framework
Check my extension
giix: a code generator for Yii.

The complete beginner's study guide for the Yii Framework
Share this topic:
Page 1 of 1

Help
This topic is locked












