From 82bc0dc17807eb33cab39131c14dc9edb068f448 Mon Sep 17 00:00:00 2001
From: William Zhang <william.zhang@tally-group.com>
Date: Tue, 14 Jan 2025 13:57:51 +1300
Subject: [PATCH] custom style option implementation

---
 framework/helpers/BaseHtml.php | 5 +++++
 framework/web/View.php         | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/framework/helpers/BaseHtml.php b/framework/helpers/BaseHtml.php
index ff81df22752..3d7bc17d772 100644
--- a/framework/helpers/BaseHtml.php
+++ b/framework/helpers/BaseHtml.php
@@ -205,6 +205,11 @@ public static function endTag($name)
      */
     public static function style($content, $options = [])
     {
+        $view = Yii::$app->getView();
+        if ($view instanceof \yii\web\View && !empty($view->styleOptions)) {
+            $options = array_merge($view->styleOptions, $options);
+        }
+
         return static::tag('style', $content, $options);
     }
 
diff --git a/framework/web/View.php b/framework/web/View.php
index 04aa5069b7c..ccc98812d9e 100644
--- a/framework/web/View.php
+++ b/framework/web/View.php
@@ -120,6 +120,13 @@ class View extends \yii\base\View
      * @see registerCssFile()
      */
     public $cssFiles = [];
+
+    /**
+     * @since 2.0.52
+     * @var array the style tag options.
+     */
+    public $styleOptions = [];
+
     /**
      * @var array the registered JS code blocks
      * @see registerJs()