type_style_example.install in Type Style 8
Installation routines for the Type Style Example Module.
File
modules/type_style_example/type_style_example.installView source
<?php
/**
* @file
* Installation routines for the Type Style Example Module.
*/
/**
* Implements hook_install().
*/
function type_style_example_install() {
$colors = [
'#F44336',
'#9C27B0',
'#2196F3',
'#009688',
'#8BC34A',
'#FFEB3B',
];
$icons = [
'description',
'face',
'favorite',
'thumb_up',
'visibility',
'wb_sunny',
];
/** @var \Drupal\node\NodeTypeInterface[] $content_types */
$content_types = \Drupal::entityTypeManager()
->getStorage('node_type')
->loadMultiple();
foreach ($content_types as $type) {
$type
->setThirdPartySetting('type_style', 'color', $colors[array_rand($colors)]);
$type
->setThirdPartySetting('type_style', 'icon', $icons[array_rand($icons)]);
$type
->save();
}
}
Functions
Name | Description |
---|---|
type_style_example_install | Implements hook_install(). |