You're right, it was a mistake to say ServicesController, etc... I would say ServicesComponent, etc...
To load components in a component with $components member: http://api.cakephp.org/1.2/class_component.html#1ffa81df593c314ae23143bb0834c8bc To dynamically load components in a controller with App::import('Component', 'YourComponent') http://api.cakephp.org/1.2/class_app.html#2a84eb340fe947c7fdc753c3bf8cd053 On 29 avr, 14:49, mixersoft <[EMAIL PROTECTED]> wrote: > I just tried to create components that inherit from a common component > base class, and found that there were problems loading components -- > especially when those components also use other components. It wasn't > that easy -- I'm not sure how you can load/declare components > dynamically in the var $controller attributes since that is static to > the class. > > if I'm doing it wrong, I'd love to have someone point out a better > way. It there a reason why subclassing controllers works better than > subclassing components? > > In my example above, my components are for importing photos from > Flickr/Facebook/etc, one each. And it always seems that most of the > code deals with either managing Sessions/Cookies/authentication keys > at those third party sites, or other state related issues like setting > variables for views, or testing for different form values before > sending the data to the model. > > On Apr 27, 8:32 pm, djiize <[EMAIL PROTECTED]> wrote: > > > and that's where MVC and OOP are very useful > > > MVC because: > > I'm pretty sure some parts of your components can be turned in Model/ > > Behavior/Datasource (gData, Flicker data access, ... are Model's > > logic) > > > OOP because: > > why your ServicesController loads all components when it only needs > > some? > > Maybe you should separate in several controllers that inherit > > ServicesController (YahooServicesController, > > GoogleServicesController, ...) > > That way, each sub-ServicesController has its own $components list. > > > Dont' forget that in CakePHP, there's still PHP ;-) > > > On 27 avr, 10:31, "Sam Sherlock" <[EMAIL PROTECTED]> wrote: > > > > you have the option of importing them when you need and keeping generall > > > required (heavily used comps in the controllers) > > > > *App::import*('*Component*'.$name) > > > > same goes for models etc > > > > at least thats as I understand. > > > > 2008/4/27 mixersoft <[EMAIL PROTECTED]>: > > > > > I am really wrestling with this one and wanted to know if others have > > > > established a best practice. > > > > > My controllers are getting to be pretty big, and different actions may > > > > need different components. Also, in the name of DRY, I have a > > > > 'services' controller that performs a lot of standard utility > > > > functions -- which may need differnt components depending on who > > > > called it. (i.e. Flickr component for Flickr stuff, Facebook component > > > > for FB, Google component for Google, etc.) > > > > > It really seems like Cake wants me to include all compoments in the > > > > controller var $compoments class attribute, so they can all be easily > > > > referenced as a class variable. But I'm looking at my 'services' > > > > controller, and that could very well have a lot of very large > > > > components. > > > > > I've tried to use App::import('Compoment', component) to load > > > > components on the fly, but when I do so I can't seem to access any > > > > components which those components need to use. (see post on Component > > > > Polymorphism). > > > > > What do people do? Is the extra overhead so nominal that I should just > > > > include everything plus the kitchen sink? Is Cake smart enough only to > > > > actually load a component when it is actually required? Has anyone > > > > else figured out how to properly load components on the fly? > > > > > TIA. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
