Skip to content
Snippets Groups Projects

remove file_save_data drupal 10

1 file
+ 11
7
Compare changes
  • Side-by-side
  • Inline
@@ -164,13 +164,17 @@ class SalesforceExampleSubscriber implements EventSubscriberInterface {
@@ -164,13 +164,17 @@ class SalesforceExampleSubscriber implements EventSubscriberInterface {
$destination = "public://user_picture/profilepic-" . $sf_data->id() . ".jpg";
$destination = "public://user_picture/profilepic-" . $sf_data->id() . ".jpg";
// Attach the new file id to the user entity.
// Attach the new file id to the user entity.
/* var \Drupal\file\FileInterface */
$file_storage = \Drupal::service('file.storage');
if ($file = file_save_data($file_data, $destination, FileSystemInterface::EXISTS_REPLACE)) {
// Create a file object.
$account->user_picture->target_id = $file->id();
$file = $file_storage->create([
}
'uri' => $destination,
else {
]);
\Drupal::logger('db')->error('failed to save profile pic for user ' . $account->id());
if ($file->save($file_data, FileSystemInterface::EXISTS_REPLACE)) {
}
$account->user_picture->target_id = $file->id();
 
}
 
else {
 
\Drupal::logger('db')->error('Failed to save profile pic for user ' . $account->id());
 
}
break;
break;
}
}
Loading