function file_create_filename in Drupal 8
Same name and namespace in other branches
- 4 includes/file.inc \file_create_filename()
- 5 includes/file.inc \file_create_filename()
- 6 includes/file.inc \file_create_filename()
- 7 includes/file.inc \file_create_filename()
Creates a full file path from a directory and filename.
If a file with the specified name already exists, an alternative will be used.
Parameters
$basename: String filename
$directory: String containing the directory or parent URI.
Return value
File path consisting of $directory and a unique filename based off of $basename.
Deprecated
in drupal:8.7.0 and is removed from drupal:9.0.0. Use \Drupal\Core\File\FileSystemInterface::createFilename().
See also
https://www.drupal.org/node/3006851
Related topics
1 call to file_create_filename()
- FileSystemDeprecationTest::testDeprecatedFileCreate in core/
tests/ Drupal/ KernelTests/ Core/ File/ FileSystemDeprecationTest.php - @expectedDeprecation file_create_filename() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::createFilename(). See https://www.drupal.org/node/3006851.
File
- core/
includes/ file.inc, line 755 - API for handling file uploads and server file management.
Code
function file_create_filename($basename, $directory) {
@trigger_error('file_create_filename() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\Core\\File\\FileSystemInterface::createFilename(). See https://www.drupal.org/node/3006851.', E_USER_DEPRECATED);
return \Drupal::service('file_system')
->createFilename($basename, $directory);
}