date_format: check if already exists
Since everything in libs/ gets autoloaded by composer - there's no easy way to override built-in modifiers.
This is an attempt at a workaround for date_format specifically, as seen within smarty_mb_str_replace
Since everything in
libs/gets autoloaded by composer
Is that true? I don't think that's true. My project has Smarty modifiers and functions overridden. Smarty loads those files on demand, not always by Composer. Just add a plugins_dir before Smarty's and that's where Smarty will look first.
$smarty->plugins_dir = [
PROJECT_INC_SMARTY . '/plugins', // Mine
PROJECT_VENDOR . '/smarty/smarty/libs/plugins', // Smarty's built-in
];
Since everything in
libs/gets autoloaded by composerIs that true? I don't think that's true. My project has Smarty modifiers and functions overridden. Smarty loads those files on demand, not always by Composer. Just add a
plugins_dirbefore Smarty's and that's where Smarty will look first.
Specified within: https://github.com/smarty-php/smarty/blob/support/4.3/composer.json#L35-L38
$smarty->plugins_dir = [ PROJECT_INC_SMARTY . '/plugins', // Mine PROJECT_VENDOR . '/smarty/smarty/libs/plugins', // Smarty's built-in ];
That's what I was using, but I get compile errors for using already declared function (because autoloader loaded the Smarty file, even before use).
Specified within: https://github.com/smarty-php/smarty/blob/support/4.3/composer.json#L35-L38
That's a class map, not functions. Functions aren't autoloaded. Maybe something else includes that file twice. Or a smarty/plugin cache. Or something. I've never had a problem with this. Buuut I have no idea which version I'm running. It would be very weird if this had changed on purpose.