You are here

protected function InstallHelper::processImage in Drupal 9

Same name and namespace in other branches
  1. 8 core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php \Drupal\demo_umami_content\InstallHelper::processImage()

Process images into media entities.

Parameters

array $data: Data of line that was read from the file.

Return value

array Data structured as a image.

1 call to InstallHelper::processImage()
InstallHelper::processContent in core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php
Process content into a structure that can be saved into Drupal.

File

core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php, line 355

Class

InstallHelper
Defines a helper class for importing default content.

Namespace

Drupal\demo_umami_content

Code

protected function processImage(array $data) {

  // Set article author.
  if (!empty($data['author'])) {
    $values['uid'] = $this
      ->getUser($data['author']);
  }
  $image_path = $this->module_path . '/default_content/images/' . $data['image'];

  // Prepare content.
  $values = [
    'name' => $data['title'],
    'bundle' => 'image',
    'langcode' => 'en',
    'field_media_image' => [
      'target_id' => $this
        ->createFileEntity($image_path),
      'alt' => $data['alt'],
    ],
  ];
  return $values;
}