Re: Trying to use Component polymorphism, How do I load a component on the fly?

2008-04-26 Thread mixersoft
Aaaah. I still have a problem. I can't seem to use components in my sub-classed component. For example, if I have the following: class RedComponent extends ColorComponent { var $components = array('Session', 'Flickr'); ... } I get the folloiwng error when I reference the component

Re: Trying to use Component polymorphism, How do I load a component on the fly?

2008-04-26 Thread mixersoft
I think I have it worked out. The following example allows me to load sub-classed Components on the fly and use them as if they were a "parent class" instance. Note that components are loaded in the controller through this static command: ColorComponent::create($this, 'Red'); an

Re: Trying to use Component polymorphism, How do I load a component on the fly?

2008-04-23 Thread mixersoft
I'm trying to follow your suggestion, but with adjustment so that the component instance is created in either a startup or beforeFilter method, instead of calling new in every action that needs this component. I think I have it done properly, but now I get an error when the Component tries to acc

Re: Trying to use Component polymorphism, How do I load a component on the fly?

2008-04-22 Thread Joel Perras
App::import('Component', 'MyComponent') will load the component. In the Component::startup() you should have: public function startup(&$controller){ $this->MyComponent = $controller->MyComponent; } so that you can then create a component instance when you need it: $this->MyComponentInstanc

Re: Trying to use Component polymorphism, How do I load a component on the fly?

2008-04-22 Thread Anthony
I'm trying to solve the same exact problem, so far unsuccessfully... Any suggestions out there? On Apr 20, 5:44 am, mixersoft <[EMAIL PROTECTED]> wrote: > I have a "parent" component that I want to use to implement an > "interface" (java style) and multple "child" components that extend > the "in

Trying to use Component polymorphism, How do I load a component on the fly?

2008-04-20 Thread mixersoft
I have a "parent" component that I want to use to implement an "interface" (java style) and multple "child" components that extend the "interface". I want my controllers to instantiate a specific "child" component, but in the code I want to reference all methods through the "parent" class or "inte