Loading file_rename.module +6 −1 Original line number Diff line number Diff line <?php /** * @file * Contains file_rename.module. */ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\file\FileInterface; Loading src/Form/FileRenameForm.php +8 −2 Original line number Diff line number Diff line Loading @@ -109,7 +109,10 @@ class FileRenameForm extends ContentEntityForm { $filepath_new = $this->getRenamedFilePath($form_state); // Rename existing file. $this->fileSystem->move($this->entity->getFileUri(), $filepath_new, FileSystemInterface::EXISTS_REPLACE); $log_args = ['@old' => $this->entity->getFilename(), '@new' => $filename_new]; $log_args = [ '@old' => $this->entity->getFilename(), '@new' => $filename_new, ]; // Invoke pre-rename hooks. $this->moduleHandler->invokeAll('file_prerename', [$this->entity]); // Update file entity. Loading @@ -126,6 +129,9 @@ class FileRenameForm extends ContentEntityForm { } } /** * Get Renamed File Path. */ protected function getRenamedFilePath(FormStateInterface $form_state) { $pathinfo = pathinfo($this->entity->getFileUri()); $old_filename = $pathinfo['filename']; Loading README.md +1 −1 File changed.Contains only whitespace changes. Show changes file_rename.info.yml +1 −1 File changed.Contains only whitespace changes. Show changes Loading
file_rename.module +6 −1 Original line number Diff line number Diff line <?php /** * @file * Contains file_rename.module. */ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; use Drupal\file\FileInterface; Loading
src/Form/FileRenameForm.php +8 −2 Original line number Diff line number Diff line Loading @@ -109,7 +109,10 @@ class FileRenameForm extends ContentEntityForm { $filepath_new = $this->getRenamedFilePath($form_state); // Rename existing file. $this->fileSystem->move($this->entity->getFileUri(), $filepath_new, FileSystemInterface::EXISTS_REPLACE); $log_args = ['@old' => $this->entity->getFilename(), '@new' => $filename_new]; $log_args = [ '@old' => $this->entity->getFilename(), '@new' => $filename_new, ]; // Invoke pre-rename hooks. $this->moduleHandler->invokeAll('file_prerename', [$this->entity]); // Update file entity. Loading @@ -126,6 +129,9 @@ class FileRenameForm extends ContentEntityForm { } } /** * Get Renamed File Path. */ protected function getRenamedFilePath(FormStateInterface $form_state) { $pathinfo = pathinfo($this->entity->getFileUri()); $old_filename = $pathinfo['filename']; Loading