you include a new component with an existing model if they have the
same name inside the controller
example:
- db table "emails" with model "Email" and "EmailComponent" both
result in $this->Email in the controller overriding each other causing
fatal errors.
example:
- including "ColorComponent" to a project using a "Color" model result
in $this->Color in the controller
same with "File", "Currency" and so on
what would be the best way to deal with it?
a)
renaming the components to its "plural" version and update all method
calls? seems not to be the best choice. all component names usually
are singular - we would then have some plural and some singular ones.
getting quite confusing. plus it feels like components should stay
singular - its kinda awkward if they are not.
b)
including components with "Component" attached (the real class name)
instead? $this->ColorComponent and $this->Color would not conflict
anymore - but this might require a core hack. and although this was
already pointed out in 1.2 tickets this was not seen as a neccessarity
from the core team.
this would require a lot of method call renaming but would probabably
be the most straightforward and future proof approach. adding new
components would not result in a farce.
c)
adding some "fake" attribute to the class name?
ColorCompComponent extends Object to be able to use it with $this-
>ColorComp->method() maybe?
Renaming the model or the component might only resolve it temporally -
until another crash comes up. Renaming either one of them to a totally
awkward name just to avoid the conflict doesnt really please me,
either :)
you wouldnt want to be forced to name the component
"MyAwesomeColor"(Component) just because you cant use the one that
would be most appropriate due to some existing db tables and their
models
d)
renaming it to a similar name that will probably never exist as a
model? like
"Coloring" or "Emailing"? this might not work for all components but
would fit in the overall framework very well. behaviours are "...able"
and components then "...ing".
thats my personal favorite after all.
PS: "color" component as well as the other ones are just exemplary for
a whole bunch of naming conflicts - in my case
i am interesting what you think
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment