drupal 7 - How to override a PHP function? -
ubercart drupal has difficulties currencies. however, overriding "uc_currency_format", can @ least background calculation give estimate of converted value. however, it's part of ubercart core, can't edit file, risk losing code after every update. also, function not have hook!
that means can think of dealing this, having module overrides function. question is...
is there way override existing php function? example, have:
function uc_currency_format($value, $sign = true, $thou = true, $dec = null) { // dont }
but when gets called, want instead execute this
function uc_currency_format_rewrite($value, $sign = true, $thou = true, $dec = null) { // }
is possible?
it seems 1 of rare times need hack core code. when comes this, try limit impact @ minimum this:
- rename original function. in case, go 'uc_currency_format_original'
- in custom module, rename 'uc_currency_format_rewrite' 'uc_currency_format'
this way, have own code running.
at next update, see in testing environment (always better test, before applying updates production sites) duplicate function name fatal error. if hook has not been implemented yet, rename original fuction, again.
this method not defined in best practice, of course. use @ own risk.
Comments
Post a Comment