I need to refactor some models and think that InheritableBehavior[1]
is the way to go. But I'm not sure about how to implement it.
Specifically, because the child models aren't associated (in the Cake
sense) with the parent, I don't understand how I can get all of the
child models when I do a find() on the parent.

Using the example from the bakery article, if I have a parent Asset
with children Document, Image, and Link, and I also have a model
Collection which hasMany Assets, how would I grab all of the child
data from CollectionController? I can see how I'd do it with 'contain'
but only if Asset was associated with Document, et al. Technically,
it's not. Not in the Cake sense, at any rate. I can see how doing a
find() on eg. Document will also fetch the parent Asset data, but
that's going in the other direction.

So, I'm wondering if I should use this behavior in conjunction with
ExtendableBehavior[2], so, continuing with the example, I'd have:

class Asset extends AppModel
{
   var $name = 'Asset';
   public $actsAs = array('Extendable');
}

App::import('Model', 'Asset');
class Image extends Asset
{
        public $useTable = 'assets';
    public $actsAs = array(
        'Inheritable'=> array('method'=>'STI')
    );
}

App::import('Model', 'Asset');
class Document extends Asset
{
        public $useTable = 'assets';
    public $actsAs = array(
       'Inheritable'=> array('method'=>'STI')
    );
}


Now, first off, I'm really not sure that using these 2 together would
work at all. Secondly, I'd much rather use Class Table Inheritance,
not Single Table. But, from my reading of Extendable, it couldn't work
with CTI. So, if anyone's done this, I'd really like some feedback.
Especially if you used CTI.

Of course, if you're only using Inheritable, I'd appreciate any comments.

[1] 
http://bakery.cakephp.org/articles/view/inheritable-behavior-missing-link-of-cake-model
[2] http://bakery.cakephp.org/articles/view/extendablebehavior

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to