Background.php in GridStack 8.2
File
src/Plugin/gridstack/stylizer/Background.php
View source
<?php
namespace Drupal\gridstack\Plugin\gridstack\stylizer;
class Background extends Color {
protected function getBackgroundColor(array $settings, $with_text = TRUE) {
$build = [];
if ($this
->getColors($settings)) {
$rgb = 'bg';
$rgba = 'rgba';
$text = 'text';
$data = $this
->getSelector($settings);
$key = isset($data['selector']) ? $data['selector'] : '';
$bg_key = isset($data['bg_selector']) ? $data['bg_selector'] : '';
if ($key && ($this
->getColor($rgba, $settings) || $this
->getColor($rgb, $settings) || $this
->getColor($text, $settings))) {
$bg = $this
->getColor($rgb, $settings) ?: '';
$bg = $this
->getColor($rgba, $settings) ?: $bg;
$text = $this
->getColor($text, $settings) ?: '';
$bg = $bg ? 'background-color:' . $bg . ';' : '';
$text = $text ? 'color:' . $text . ';' : '';
if ($data['overlay']) {
if ($text && $with_text) {
$build[$key] = $text;
}
if ($bg) {
$build[$bg_key] = $bg;
}
}
else {
if ($bg || $text) {
$build[$key] = $with_text ? $bg . $text : $bg;
}
}
}
$build = array_unique($build);
}
return $build;
}
}