fix: Add new IsBright helper to replace old Tools::GetBrightness

This is used from prestashop itself but I needed to add it as a smarty helper
This commit is contained in:
2025-11-19 17:17:10 +01:00
parent 3a0468879f
commit 60e57a5df6
2 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,7 @@ namespace Oksydan\Module\IsThemeCore\Core\Smarty;
use Oksydan\Module\IsThemeCore\Core\Webp\WebpPictureGenerator;
use Oksydan\Module\IsThemeCore\Form\Settings\WebpConfiguration;
use PrestaShop\PrestaShop\Core\Util\ColorBrightnessCalculator;
class SmartyHelperFunctions
{
@ -189,4 +190,9 @@ class SmartyHelperFunctions
return $content;
}
public static function isBright($hexColor)
{
$calculator = new ColorBrightnessCalculator();
return $calculator->isBright($hexColor);
}
}

View File

@ -51,5 +51,10 @@ public function hookActionDispatcherBefore(): void
} else {
return;
}
if (!isset($this->context->smarty->registered_plugins['modifier']['is_bright'])) {
$this->context->smarty->registerPlugin('modifier', 'is_bright', ['Oksydan\Module\IsThemeCore\Core\Smarty\SmartyHelperFunctions', 'isBright']);
} else {
return;
}
}
}