function file_destination in Drupal 8
Same name and namespace in other branches
- 6 includes/file.inc \file_destination()
- 7 includes/file.inc \file_destination()
Determines the destination path for a file.
Parameters
$destination: A string specifying the desired final URI or filepath.
$replace: Replace behavior when the destination file already exists.
- FILE_EXISTS_REPLACE - Replace the existing file.
- FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique.
- FILE_EXISTS_ERROR - Do nothing and return FALSE.
Return value
The destination filepath, or FALSE if the file already exists and FILE_EXISTS_ERROR is specified.
Deprecated
in drupal:8.7.0 and is removed from drupal:9.0.0. Use \Drupal\Core\File\FileSystemInterface::getDestinationFilename().
See also
https://www.drupal.org/node/3006851
Related topics
2 calls to file_destination()
- FileSystemDeprecationTest::testDeprecatedFileDestination in core/
tests/ Drupal/ KernelTests/ Core/ File/ FileSystemDeprecationTest.php - @expectedDeprecation file_destination() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\File\FileSystemInterface::getDestinationFilename(). See https://www.drupal.org/node/3006851.
- file_unmanaged_prepare in core/
includes/ file.inc - Internal function that prepares the destination for a file_unmanaged_copy or file_unmanaged_move operation.
File
- core/
includes/ file.inc, line 588 - API for handling file uploads and server file management.
Code
function file_destination($destination, $replace) {
@trigger_error('file_destination() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \\Drupal\\Core\\File\\FileSystemInterface::getDestinationFilename(). See https://www.drupal.org/node/3006851.', E_USER_DEPRECATED);
return \Drupal::service('file_system')
->getDestinationFilename($destination, $replace);
}