Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By tim.plunkett on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Description:
File system functions are now available as methods on the 'file_system' service, and are found in \Drupal\Core\File\FileSystem
Before:
drupal_chmod($uri);
After:
\Drupal::service('file_system')->chmod($uri)
Old function | New method |
---|---|
drupal_move_uploaded_file() | \Drupal\Core\File\FileSystem::moveUploadedFile() |
drupal_chmod() | \Drupal\Core\File\FileSystem::chmod() |
drupal_unlink() | \Drupal\Core\File\FileSystem::unlink() |
drupal_realpath() | \Drupal\Core\File\FileSystem::realpath() |
drupal_dirname() | \Drupal\Core\File\FileSystem::dirname() |
drupal_basename() | \Drupal\Core\File\FileSystem::basename() |
drupal_mkdir() | \Drupal\Core\File\FileSystem::mkdir() |
drupal_rmdir() | \Drupal\Core\File\FileSystem::rmdir() |
drupal_tempnam() | \Drupal\Core\File\FileSystem::tempnam() |
file_htaccess_lines() |
\Drupal\Component\PhpStorage\FileStorage::htaccessLines() |
Additionally, the constants FILE_CHMOD_DIRECTORY and FILE_CHMOD_FILE were deprecated in favor of \Drupal\Core\File\FileSystem::CHMOD_DIRECTORY and \Drupal\Core\File\FileSystem::CHMOD_FILE.
The following functions have been deprecated and moved to StreamWrapperManager
Old function/method | New method |
---|---|
FileSystem::uriScheme() file_uri_scheme() |
StreamWrapperManager::getScheme() |
FileSystem::validScheme() file_stream_wrapper_valid_scheme() |
\Drupal::service('stream_wrapper_manager')->isValidScheme() |
Impacts:
Module developers