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 "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 "inteface" > > class ParentComponent extends Object {} > > class TypeAComponent extends InterfaceComponent { > function someMethod() { return "a";} > > } > > class TypeBComponent extends InterfaceComponent { > function someMethod() { return 'b';} > > } > > class MyController extends AppController { > var $components('TypeAComponent'); > > function example() { > $result = $this->Parent->someMethod(); > } > > } > > The example above works fine. But I cannot figure out how to load > 'TypeAComponent' or 'TypeBComponent' dynamically. How can I set > MyConfroller->components BEFORE the controller loads the components? > Or how do I load additional components afterwards? > > I tried this in ParentComponent, but while the subclassed components > constructors were called properly, the components were not "loaded" > the same way (i.e. the child component's var $component array were not > loaded, i.e. Session.) > > class ParentComponent extends Object { > static function create($type) { > switch ($type) { > case 'TypeA': > > include_once(dirname(__FILE__).DS.'typeA.php'); > return new TypeAComponent(); > break; > case 'TypeB': > > include_once(dirname(__FILE__).DS.'typeB.php'); > return new TypeBComponent(); > break; > } > } > > } --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---