You are here

function social_topic_allowed_values_function in Open Social 10.1.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_topic/social_topic.module \social_topic_allowed_values_function()
  2. 10.0.x modules/social_features/social_topic/social_topic.module \social_topic_allowed_values_function()
  3. 10.2.x modules/social_features/social_topic/social_topic.module \social_topic_allowed_values_function()

Sets dynamic allowed values for the topic type icon field.

2 string references to 'social_topic_allowed_values_function'
field.storage.taxonomy_term.field_topic_type_icon.yml in modules/social_features/social_topic/config/install/field.storage.taxonomy_term.field_topic_type_icon.yml
modules/social_features/social_topic/config/install/field.storage.taxonomy_term.field_topic_type_icon.yml
social_topic_update_8907.yml in modules/social_features/social_topic/config/static/social_topic_update_8907.yml
modules/social_features/social_topic/config/static/social_topic_update_8907.yml

File

modules/social_features/social_topic/social_topic.module, line 299
The Social topic module.

Code

function social_topic_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;
}