function termcase_taxonomy_term_presave in Termcase 8
Implements hook_ENTITY_TYPE_presave() for taxonomy_term entities.
File
- ./
termcase.module, line 150 - The Termcase module gives you the option to specify specific case-formatting on terms.
Code
function termcase_taxonomy_term_presave(EntityInterface $entity) {
$vocab_machine_name = $entity
->getVocabularyId();
$config = \Drupal::config('termcase.settings');
$termcase_mode = $config
->get('termcase_options_' . $vocab_machine_name);
$term_name = $entity
->getName();
if ($termcase_mode) {
$term_name = _termcase_convert_string_to_case($term_name, $termcase_mode);
}
$entity
->setName($term_name);
}