Below an answer i got by mail from francois, i don't see it as a
reply, so incase anyone is looking for the explanation later, tnx
francois

Hi,

Due to late static binding not being implemented yet in PHP, what you
ask is impossible... Check this link for more info:

http://de2.php.net/manual/de/function.get-class.php#77698

But, there is a workaround. Say you wrote a `myFinder` class with
custom methods that you want to use in several models:

    class myFinder extends DbFinder
    {
      // custom methods
      ...
    }

If you call:

    $finder = myFinder::from('Article');

then `$finder` is an instance of `DbFinder` - this is the Late Static
Binding problem.

But if you define a custom `ArticleFinder` class extending `myFinder`,
as follows:

    class ArticleFinder extends myFinder
    {
      protected $class = 'Article';
    }

Then calling:

    $finder = DbFinder::from('Article');

will return an `ArticleFinder` instance, which inherits from
`myFinder`. And that means you can use your custom finder methods on
several models.

Hope this helps,

François



On Oct 7, 7:50 pm, DigitalBase <[EMAIL PROTECTED]> wrote:
> I want to extend fromdbFinderproviding several (read : different)
> classes to have special functionality.
>
> As i read on francois's blog, extending fromdbFindershould be very
> easy.
>  http://redotheweb.com/2008/09/25/sorting-by-custom-column-in-the-symf...
>
> So what i did
>
> class MyDbFinder extendsDbFinder() {
>   public function doStuff() {
>       return $this->...->....->...;
>   }
>
> }
>
> No when i try to call that finder
>
> $finder = MyDbFinder::from("ProfileProject")->doStuff();
>
> I get this :
>
> Undefined method *s::sfModelFinder()
>
> Looking into the error i noticed the $finder object isn't even an
> instance of MyDbFinder, but ofDbFinder.
> When i name my class ProfileProjectFinder it does work. Why is that ?
>
> I need shareddbFinderfunctionality without having to create a finder
> object each time.
>
> Am i missing something here ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" 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/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to