function thunder_media_file_create in Thunder 6.1.x
Same name and namespace in other branches
- 8.5 modules/thunder_media/thunder_media.module \thunder_media_file_create()
- 8.2 modules/thunder_media/thunder_media.module \thunder_media_file_create()
- 8.3 modules/thunder_media/thunder_media.module \thunder_media_file_create()
- 8.4 modules/thunder_media/thunder_media.module \thunder_media_file_create()
- 6.0.x modules/thunder_media/thunder_media.module \thunder_media_file_create()
Implements hook_ENTITY_TYPE_create().
File
- modules/
thunder_media/ thunder_media.module, line 14 - Contains media related functions.
Code
function thunder_media_file_create(File $entity) {
$config = \Drupal::config('thunder_media.settings');
if ($config
->get('enable_filename_transliteration')) {
$pathinfo = pathinfo($entity
->getFilename());
/** @var \Drupal\pathauto\AliasCleaner $aliasCleaner */
$aliasCleaner = \Drupal::service('pathauto.alias_cleaner');
// Check for needed pathinfo array keys.
if (!empty($pathinfo['filename']) && !empty($pathinfo['extension'])) {
$cleanFilename = $aliasCleaner
->cleanString($pathinfo['filename']) . '.' . $pathinfo['extension'];
$entity
->setFilename($cleanFilename);
}
}
}