Custom class helper not initialized

Status
Not open for further replies.

lcollong

FabriKant d'applications web
Hi,

Finally, I'am currently doing my first real migration from F3/J3 to F4/J4. Up to now evertything is going smoothly. However I think we miss a class initialization.

I'm using the Custom class in /libraries/fabrik/fabrik/fabrik/Helpers/Custom.php to load static function reachable from where ever you are (eval, calc, default values, etc..).
There is a function called __initStatic used to initialize all static variables which can be used in the custom static functions.

For example, for a default value in an element I use :
return \Fabrik\Helpers\Custom::getParametre('default_session_size');

"getParametre" allows to retrieve my application parameters from a private array. This array is initialized inside the __initStatic func.

The problem is that it is never initialized. If I add the following line :
\Fabrik\Helpers\Custom::__initStatic();
somewhere in the form, everything works as in F3. But I think this should be called by Fabrik's model as part as helpers setup.

I don't know where it was initialized in F3. Any idea so I could add it as part of the F4 setup ?
 
It's in libraries\fabrik\fabrik\include.php and it seems the initialization got removed somewhere on the F4 work.
Can you try to change line 248 ff
Code:
    private function helper($class)
    {
        if (!strstr($class, 'Fabrik\Helpers'))
        {
            return;
        }

        $className = str_replace('\', '/', $class);
        //$file  = explode('/', $class);
        //$file  = strtolower(array_pop($file));
        $path = preg_replace('#Fabrik\/Helpers\/#', '/libraries/fabrik/fabrik/fabrik/Helpers/', $className);
        $path  = JPATH_SITE . $path . '.php';

        if (file_exists($path))
        {
            require_once $path;

            if (is_callable(array($class, '__initStatic')))
            {
                $class::__initStatic();
            }
        }
    }
 
Probably missing something.
I did a trace on $class in this function and it is never called with "Custom" hence no way to answer "true" to the is_callable test nor to init.
 
I never used it and I don't have a meaningful example.
I copied F4 CustomSample.php to Custom.php, changed class CustomSample to class Custom and added die('custom init'); in __initStatic()
With the modified include.php it's "dying" ;)
 
U right !
I have restart from scratch (the 2 files involved !) and now custom class is getting initiated !
well done !
Thanks
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top