function _addanother_set_content_type_configs in Add Another 8
Set addanother options for existing content types.
2 calls to _addanother_set_content_type_configs()
- addanother_install in ./
addanother.install - Implements hook_install().
- addanother_update_8001 in ./
addanother.install - Update existing content with default values if has not been already set.
File
- ./
addanother.install, line 27 - Contains install and update functions for addanother module.
Code
function _addanother_set_content_type_configs($check_existing = FALSE) {
$types = array_keys(NodeType::loadMultiple());
$configs = [
'button',
'message',
'tab',
'tab_edit',
];
/* @var \Drupal\Core\Config\Config $config_factory */
$config_factory = \Drupal::service('config.factory')
->getEditable('addanother.settings');
foreach ($types as $type) {
foreach ($configs as $config) {
if ($check_existing && !is_null($config_factory
->get("{$config}.{$type}"))) {
continue 2;
}
$config_factory
->set("{$config}.{$type}", $config_factory
->get("default_{$config}"));
}
}
$config_factory
->save();
}