Class has Method but not Documented in API

Permalink
I'm working with c5 since 2008 and with php for more than 15 years, but maybe there is something basic I actually didn't understand:

I searched for the correct method to get the thumbnail URL for a file in the API documentation, but /Concrete/Core/Entity/File/File has no such method. So I searched the web for some answer and found $file->getThumbnailURL(). And it worked. Now I wondered what sort of class my $file could be and with get_class() I found it was this same /Concrete/Core/Entity/File/File! Now I searched the source code of this class and also didn't find any getThumbailURL method, whereas I found it in /Concrete/Core/Entity/File/Version.

Can anyone get me a hint? It seems I'm missing some basic concept...

cgrauer
 
mnakalay replied on at Permalink Best Answer Reply
mnakalay
Hello, you are right, it is puzzling but there's an explanation. In Concrete/Core/Entity/File/File you have the following
/**
     * For all methods that file does not implement, we pass through to the currently active file version object.
     */
    public function __call($nm, $a)
    {
        $fv = $this->getApprovedVersion();
        if (is_null($fv)) {
            return;
        }
        return call_user_func_array([$fv, $nm], $a);
    }

So any non-existent method you call on an object of File type is automatically called on its corresponding Version object. That's why it's working.
cgrauer replied on at Permalink Reply
cgrauer
Hrmpf, I knew it would be as easy as that... while reading, I remember the __call() function, but I didn't came up to it. Thanks a lot for your help! Makes me sleep very well tonight :-))