src/template/Html.php
public static function addCssStyle(&$options, $style, $overwrite = true)
    {
        if (!empty($options['style'])) {
            $oldStyle = static::cssStyleToArray($options['style']);
            $newStyle = is_array($style) ? $style : static::cssStyleToArray($style);
            if (!$overwrite) {
                foreach ($newStyle as $property => $value) {
                    if (isset($oldStyle[$property])) {
                        unset($newStyle[$property]);
                    }
                }
            }
            $style = static::cssStyleFromArray(array_merge($oldStyle, $newStyle));
        }
        $options['style'] = $style;
    }
public static function addCssStyle(&$options, $style, $overwrite = true)
    {
        if (!empty($options['style'])) {
            $oldStyle = static::cssStyleToArray($options['style']);
            $newStyle = is_array($style) ? $style : static::cssStyleToArray($style);
            if (!$overwrite) {
                foreach ($newStyle as $property => $value) {
                    if (isset($oldStyle[$property])) {
                        unset($newStyle[$property]);
                    }
                }
            }
            $style = static::cssStyleFromArray(array_merge($oldStyle, $newStyle));
        }
        $options['style'] = $style;
    }
public static function addCssStyle ( & $ options , $ style , $ overwrite = true ) { if ( ! empty ( $ options [ 'style' ] ) ) { $ oldStyle = static :: cssStyleToArray ( $ options [ 'style' ] ) ; $ newStyle = is_array ( $ style ) ? $ style : static :: cssStyleToArray ( $ style ) ; if ( ! $ overwrite ) { foreach ( $ newStyle as $ property => $ value ) { if ( isset ( $ oldStyle [ $ property ] ) ) { unset ( $ newStyle [ $ property ] ) ; } } } $ style = static :: cssStyleFromArray ( array_merge ( $ oldStyle , $ newStyle ) ) ; } $ options [ 'style' ] = $ style ; }
Adds the specified CSS style to the HTML options.

If the options already contain a `style` element, the new style will be merged
with the existing one. If a CSS property exists in both the new and the old styles,
the old one may be overwritten if `$overwrite` is true.

For example,

```php
Html::addCssStyle($options, 'width: 100px; height: 200px');
```

@param array $options the HTML options to be modified.
@param string|array $style the new style string (e.g. `'width: 100px; height: 200px'`) or
array (e.g. `['width' => '100px', 'height' => '200px']`).
@param boolean $overwrite whether to overwrite existing CSS properties if the new style
contain them too.
@see removeCssStyle()
@see cssStyleFromArray()
@see cssStyleToArray()
Adds the specified CSS style to the HTML options .