php - __autoload disaster - conflicts with Joomla -
I have just changed all my code to use __autoload so that it can be found with Joomla Autoloader is. I integrate to register my users with Joomla in some cases.
allows me lots of autoloaders with spl_autoload_register ().
What should I do?
> Update : This is Joomla
This file loads from /library/loader.php
Function __autoload ($ class) {if (JL loader :: load ($ square)) {return true; } return false; Need_once (JPATH_BASE .DD. 'Contains' DD. 'Defines.php'); Need_once (JPATH_BASE.DD. 'Included' .ds 'framework .php'); // auto loader so that it does not interfere with my spl_autoload_register ('__ autoload');
This my autoload looks like this:
& lt ;? Php / import function myAutoload ($ class_name) {$ path = str_replace ('_', '/', $ Class_name); Include $ path '.php'; }? & Gt; Spl_autoload_register ('myAutoload', false, true);
I was called for the first time and Joomla one second, however, the app still can not find Joomla classes.
Update 3:
after running:
echo "PRE: myAutoload:". Spl_autoload_functions () "& lt; br / & gt;"; Spl_autoload_register ('myAutoload', false, true); Resonant "post: myAutoload:". Spl_autoload_functions () "& lt; br / & gt;";
and
resonance "pre: Joomla AUTOload:". Spl_autoload_functions () "& lt; br / & gt;"; // auto loader so that it does not interfere with my spl_autoload_register ('__ autoload'); Echo "Post: Joomla Auto Laud:". Spl_autoload_functions () "& lt; br / & gt;";
My output was: PRE: myAutoload: POST: myAutoload: Array
Update 4:
I had to change Joomla import on:
need_once (JPATH_BASE.DS.'libraries'.DS.'loader.php '); Echo "Pre: Joomla AUTOload:". Var_dump (spl_autoload_functions ()). "& Lt; br / & gt;"; // auto loader so that it does not interfere with my spl_autoload_register ('__ autoload'); Echo "Post: Joomla Auto Laud:". Var_dump (spl_autoload_functions ()). "& Lt; br / & gt;"; Need_once (JPATH_BASE .DD. 'Contains' DD. 'Defines.php'); Need_once (JPATH_BASE.DD. 'Included' .ds 'framework .php');
Here is the output
PRE: myAutoload: array 0 = & gt; String 'myAutoload' (length = 10) Posted: myAutoload: array 0 = & gt; String 'myAutoload' (length = 10) Pre: Joomla auto-lock: array 0 = & gt; String 'myAutoload' (length = 10) 1 = & gt; String '__autolod' (length = 10) Post: Joomla AUTOload:
I have done this job after adding these Joomla files
Need_once (JPATH_BASE .ds. 'Include' DD. 'Defines.php'); Need_once (JPATH_BASE.DD. 'Included' .ds 'framework .php');
spl_autoload_functions () returns nothing, so somehow Joomla is filling it.
You should decide which autoload function should be preferred over any one, and Use spl_autoload_register ()
(see the third argument). How is Joomla Autoload Function Registered?
Comments
Post a Comment