You are here

function _social_topic_get_term_id_by_name in Open Social 10.2.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_topic/social_topic.install \_social_topic_get_term_id_by_name()
  2. 10.0.x modules/social_features/social_topic/social_topic.install \_social_topic_get_term_id_by_name()
  3. 10.1.x modules/social_features/social_topic/social_topic.install \_social_topic_get_term_id_by_name()

Find topic type term by name.

1 call to _social_topic_get_term_id_by_name()
social_topic_update_8908 in modules/social_features/social_topic/social_topic.install
Add icons to default topic types.

File

modules/social_features/social_topic/social_topic.install, line 387
Install, update and uninstall functions for the social_topic module.

Code

function _social_topic_get_term_id_by_name($term_name) {
  $terms = \Drupal::entityTypeManager()
    ->getStorage('taxonomy_term')
    ->loadByProperties([
    'name' => $term_name,
    'vid' => 'topic_types',
  ]);
  $term = reset($terms);
  return !empty($term) ? $term : FALSE;
}