Skip to content
Snippets Groups Projects
Commit 661e9adb authored by James Wilson's avatar James Wilson
Browse files

Issue #3391867 by marthinal, jwilson3: Deprecated function Error Message when using CKEeditor5

parent 5c86f4f1
No related branches found
No related tags found
1 merge request!4Issue #3391867 by marthinal, jwilson3: Deprecated function Error Message when using CKEeditor5
......@@ -15,10 +15,11 @@ function filename_transliteration_file_field_values_init(EntityInterface $entity
if (_site_has_core_transliteration_enabled()) {
return;
}
$filename_postprocessor = Drupal::service('filename_transliteration.postprocessor');
$filename = $entity->getFilename();
$filename = $filename_postprocessor->process($filename);
$entity->setFilename($filename);
if ($filename = $entity->getFilename()) {
$filename_postprocessor = Drupal::service('filename_transliteration.postprocessor');
$filename = $filename_postprocessor->process($filename);
$entity->setFilename($filename);
}
}
/**
......@@ -29,15 +30,17 @@ function filename_transliteration_file_presave(EntityInterface $entity) {
return;
}
$filename_postprocessor = Drupal::service('filename_transliteration.postprocessor');
$new_filename = $filename_postprocessor->process($entity->getFilename());
$file_system = \Drupal::service('file_system');
if ($new_filename != $file_system->basename($entity->getFileUri())) {
$uri = $entity->getFileUri();
$directory = $file_system->dirname($uri);
$uri = str_ends_with($directory, '/') ? $directory . $new_filename : $directory . '/' . $new_filename;
if ($new_uri = $file_system->move($entity->getFileUri(), $uri, FileSystemInterface::EXISTS_RENAME)) {
$entity->set('uri', $new_uri);
$entity->set('filename', $file_system->basename($new_uri));
if ($filename = $entity->getFilename()) {
$new_filename = $filename_postprocessor->process($filename);
$file_system = \Drupal::service('file_system');
if ($new_filename != $file_system->basename($entity->getFileUri())) {
$uri = $entity->getFileUri();
$directory = $file_system->dirname($uri);
$uri = str_ends_with($directory, '/') ? $directory . $new_filename : $directory . '/' . $new_filename;
if ($new_uri = $file_system->move($entity->getFileUri(), $uri, FileSystemInterface::EXISTS_RENAME)) {
$entity->set('uri', $new_uri);
$entity->set('filename', $file_system->basename($new_uri));
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment