function social_event_type_allowed_values_function in Open Social 10.1.x
Same name and namespace in other branches
- 10.3.x modules/social_features/social_event/modules/social_event_type/social_event_type.module \social_event_type_allowed_values_function()
- 10.0.x modules/social_features/social_event/modules/social_event_type/social_event_type.module \social_event_type_allowed_values_function()
- 10.2.x modules/social_features/social_event/modules/social_event_type/social_event_type.module \social_event_type_allowed_values_function()
Sets dynamic allowed values for the event type icon field.
2 string references to 'social_event_type_allowed_values_function'
- field.storage.taxonomy_term.field_event_type_icon.yml in modules/
social_features/ social_event/ modules/ social_event_type/ config/ install/ field.storage.taxonomy_term.field_event_type_icon.yml - modules/social_features/social_event/modules/social_event_type/config/install/field.storage.taxonomy_term.field_event_type_icon.yml
- social_event_type_update_8902.yml in modules/
social_features/ social_event/ modules/ social_event_type/ config/ static/ social_event_type_update_8902.yml - modules/social_features/social_event/modules/social_event_type/config/static/social_event_type_update_8902.yml
File
- modules/
social_features/ social_event/ modules/ social_event_type/ social_event_type.module, line 114 - The Social event type module.
Code
function social_event_type_allowed_values_function(FieldStorageConfig $definition, ContentEntityInterface $entity = NULL, $cacheable) {
$theme_path = drupal_get_path('theme', 'socialbase');
$icon_files = \Drupal::service('file_system')
->scanDirectory(DRUPAL_ROOT . '/' . $theme_path . '/components/06-libraries/icons/source', '/^icon-.*\\.svg$/', [
'recurse' => FALSE,
]);
$options = [];
foreach ($icon_files as $file) {
$options[$file->name] = $file->name;
}
return $options;
}