annotate vendor/chi-teck/drupal-code-generator/templates/d8/hook/file_copy.twig @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
rev   line source
Chris@0 1 /**
Chris@0 2 * Implements hook_file_copy().
Chris@0 3 */
Chris@0 4 function {{ machine_name }}_file_copy(Drupal\file\FileInterface $file, Drupal\file\FileInterface $source) {
Chris@0 5 // Make sure that the file name starts with the owner's user name.
Chris@0 6 if (strpos($file->getFilename(), $file->getOwner()->name) !== 0) {
Chris@0 7 $file->setFilename($file->getOwner()->name . '_' . $file->getFilename());
Chris@0 8 $file->save();
Chris@0 9
Chris@0 10 \Drupal::logger('file')->notice('Copied file %source has been renamed to %destination', ['%source' => $source->filename, '%destination' => $file->getFilename()]);
Chris@0 11 }
Chris@0 12 }