function colors_create_css in Colors 8
Same name and namespace in other branches
- 7 colors.module \colors_create_css()
Retrieves or generates a CSS with a given module's selector.
Parameters
string $caller: A module that implements hook_colors_build_selector().
Return value
string The generated CSS.
File
- ./
colors.module, line 210 - Controls assigning colors to entities.
Code
function colors_create_css($caller) {
$config = \Drupal::configFactory()
->getEditable('colors.settings');
$order = $config
->get('order');
$plugins = \Drupal::service('plugin.manager.colors')
->getDefinitions();
$order['node'] = 0;
$order['vocabulary'] = 1;
$css = [];
foreach ($plugins as $entity => $plugin) {
if (isset($order[$entity])) {
$css[$order[$entity]][] = colors_get_class_names($entity);
}
}
ksort($css);
$classes = [];
foreach ($css as $groups) {
$array = [];
foreach ($groups as $group) {
$array = array_merge($array, $group);
}
$classes = array_merge($classes, $array);
}
$config = colors_get_info();
$colors = colors_get_palette($config);
$css = colors_build_css($classes, $colors, $caller);
return $css;
}