$this->currentUser =
$currentUser;
} /**
* {@inheritdoc}
*/
public function writeData(string
$data, string
$destination, int
$replace = FileSystemInterface::EXISTS_RENAME
): FileInterface
{ if (!
$this->streamWrapperManager->
isValidUri($destination)) { throw new InvalidStreamWrapperException("Invalid stream wrapper: {
$destination}"
);
} $uri =
$this->fileSystem->
saveData($data,
$destination,
$replace);
return $this->
createOrUpdate($uri,
$destination,
$replace === FileSystemInterface::EXISTS_RENAME
);
} /**
* Create a file entity or update if it exists.
*
* @param string $uri
* The file URI.
* @param string $destination
* The destination URI.
* @param bool $rename
* Whether to rename the file.
*
* @return \Drupal\file\Entity\File|\Drupal\file\FileInterface
* The file entity.
*
* @throws \Drupal\Core\Entity\EntityStorageException
* Thrown when there is an error saving the file.
*/