Commit e15c02a9 authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3258410: Update Varbase profile from ~8.8.0 to ~9.0.0 on the Vardoc...

Issue #3258410: Update Varbase profile from ~8.8.0 to ~9.0.0 on the Vardoc 4.0.x branch to work with Drupal ~9
parent 432461b4
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ use Drupal\Core\Config\InstallStorage;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Config\FileStorage;
use Vardot\Entity\EntityDefinitionUpdateManager;
use Drupal\Core\File\FileSystemInterface;

/**
 * Implements hook_install().
@@ -154,8 +155,8 @@ function vardoc_profile_install() {
    ->set('field_last_name', 'Webmaster');

  // Create avatar file entity.
  $data = file_get_contents(drupal_get_path('module', 'vardoc_profile') . '/images/avatar.png');
  $file = file_save_data($data, 'public://avatar.png', FILE_EXISTS_REPLACE);
  $data = file_get_contents(\Drupal::service('extension.path.resolver')->getPath('module', 'vardoc_profile') . '/images/avatar.png');
  $file = \Drupal::service('file.repository')->writeData($data, 'public://avatar.png', FileSystemInterface::EXISTS_REPLACE);
  // Attach the file into user profile image and then save it.
  $user->field_profile_image->setValue(['target_id' => $file->id()]);
  $user->save();