Hello!

While we're using agavi, we'd like to autoload certain of our own classes which will reside outside any of the lib directories normally used by the webbapps. Since we'd like to autoload classes (persistance classes mostly), we'd very much like to use constants (set up in config.php) pointing to the base directory of our libs.

However, the replaceConstants() method in the ConfigHandler class contains an array of constants to be replaced, which does not allow us to use our own specified constants.

I have alterted the replaceConstants method to replace every constant (as defined by %CONSTANT_NAME%) if the constant is defined, otherwise it will be left as it was.

Is this interesting to the Agavi community?

This is my replaceConstants():

   public static function & replaceConstants ($value)
   {

       $value = preg_replace_callback(
           '/\%(\w+?)\%/',
           create_function(
               '$match',
               '$constant = $match[1]; ' .
'return (defined($match[1]) ? constant($constant) : "%".$constant."%");'),
               $value,
               1);

       return $value;
   }

Please note that it limits the number of constants to one per line (iterating the preg_replace_callback(...) can be done if multiple constants are used in the same value).

Best Regards,

Johan Mjönes

--
Johan Mjönes
Programmer
Phone: +46 8 789 12 00
Fax: +46 8 789 12 12
Cell: +46 7 052 838 55
E-mail: [EMAIL PROTECTED]
Internet: www.ongame.com


This e-mail (including attachments) is strictly confidential and intended 
solely for designated recipient(s). It contains privileged and confidential 
information. If you have received this e-mail in error, you must not 
disseminate, copy, distribute or take any action in reliance on it. Please 
notify us immediately and delete this e-mail and any attachments. Thank you.

_______________________________________________
agavi-dev mailing list
[email protected]
http://labworkz.com/cgi-bin/mailman/listinfo/agavi-dev

Reply via email to