function FileSystemInterface::saveData

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::saveData()
  2. 10 core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::saveData()
  3. 11.x core/lib/Drupal/Core/File/FileSystemInterface.php \Drupal\Core\File\FileSystemInterface::saveData()

Saves a file to the specified destination without invoking file API.

This function is identical to file_save_data() except the file will not be saved to the {file_managed} table and none of the file_* hooks will be called.

Parameters

string $data: A string containing the contents of the file.

string $destination: A string containing the destination location. This must be a stream wrapper URI.

int $replace: Replace behavior when the destination file already exists:

Return value

string A string with the path of the resulting file, or FALSE on error.

Throws

\Drupal\Core\File\Exception\FileException Implementation may throw FileException or its subtype on failure.

See also

\Drupal\file\FileRepositoryInterface::writeData()

1 method overrides FileSystemInterface::saveData()
FileSystem::saveData in core/lib/Drupal/Core/File/FileSystem.php
Saves a file to the specified destination without invoking file API.

File

core/lib/Drupal/Core/File/FileSystemInterface.php, line 387

Class

FileSystemInterface
Provides an interface for helpers that operate on files and stream wrappers.

Namespace

Drupal\Core\File

Code

public function saveData($data, $destination, $replace = self::EXISTS_RENAME);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.