So far I didn't come to a better solution than just wrapping the
methods I want to implement:

class AppModel extends Model {
  function someFunction($params) {
    return BetterModel::someFunction($params);
  }
}

But I remember that there's some OOP function in PHP5 that catches
missing methods, right? In CakePHP, what is done with it? I know that
I get "error in your sql syntax" or something when calling a not
existing method, so I think CakePHP already uses this method for
something specific, but I'm going to investigate this further. Maybe I
can use it for my purpose (sending calls to not existing methods to a
module or something), too. :-)

On Mon, Nov 22, 2010 at 6:13 PM, psybear83 <psybea...@gmail.com> wrote:
> Hi all
>
> I have some functionality in my AppModel that I'd like to publish as a
> plugin or so, so I can re-use the code in other projects.
>
> So far it looks like this:
>
> class AppModel extends Model {
>  function readRandom() {}
> }
>
> Now one possibility is to extract my functionality into a class that
> will be put between AppModel and Model:
>
> class BetterModel extends Model {
>  function readRandom() {}
> }
>
> class AppModel extends BetterModel {
> }
>
> But this isn't very flexible be cause I'm constructing a fixed
> inheritance chain this way. In every project I'd have to put this
> manually into my AppModel - when only having one such feature-rich
> model this isn't a big problem, but what when I have several more
> feature-rich models? AppModelWithFunctionality,
> AppModelWithMoreFunctionality, AppModelWithEvenMoreFunctionality etc.?
> Then the inheritance chain gets really awkward and isn't flexible
> anymore when differently combining those functionalities in different
> projects.
>
> So is there a solution for this? With behaviors one can create awesome
> functionality that is run automatically, but I don't see that they
> would help me in solving my problem...? Or do I miss something?
>
> Thanks a lot
> Josh
>
> 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+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
>

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to