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:
@ -4,6 +4,7 @@ namespace Oksydan\Module\IsThemeCore\Core\Smarty;
|
|||||||
|
|
||||||
use Oksydan\Module\IsThemeCore\Core\Webp\WebpPictureGenerator;
|
use Oksydan\Module\IsThemeCore\Core\Webp\WebpPictureGenerator;
|
||||||
use Oksydan\Module\IsThemeCore\Form\Settings\WebpConfiguration;
|
use Oksydan\Module\IsThemeCore\Form\Settings\WebpConfiguration;
|
||||||
|
use PrestaShop\PrestaShop\Core\Util\ColorBrightnessCalculator;
|
||||||
|
|
||||||
class SmartyHelperFunctions
|
class SmartyHelperFunctions
|
||||||
{
|
{
|
||||||
@ -189,4 +190,9 @@ class SmartyHelperFunctions
|
|||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
public static function isBright($hexColor)
|
||||||
|
{
|
||||||
|
$calculator = new ColorBrightnessCalculator();
|
||||||
|
return $calculator->isBright($hexColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,5 +51,10 @@ public function hookActionDispatcherBefore(): void
|
|||||||
} else {
|
} else {
|
||||||
return;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user