You are here

protected function DemoGroup::prepareFiles in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()
  2. 8 modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()
  3. 8.2 modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()
  4. 8.3 modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()
  5. 8.4 modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()
  6. 8.5 modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()
  7. 8.6 modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()
  8. 8.7 modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()
  9. 8.8 modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()
  10. 10.3.x modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()
  11. 10.1.x modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()
  12. 10.2.x modules/custom/social_demo/src/DemoGroup.php \Drupal\social_demo\DemoGroup::prepareFiles()

Prepares an array with list of files to set as field value.

Parameters

string $files: The uuid for the file.

Return value

array Returns an array.

1 call to DemoGroup::prepareFiles()
DemoGroup::createContent in modules/custom/social_demo/src/DemoGroup.php
Creates content.

File

modules/custom/social_demo/src/DemoGroup.php, line 214

Class

DemoGroup
Class DemoGroup.

Namespace

Drupal\social_demo

Code

protected function prepareFiles($files) {
  $values = [];
  foreach ($files as $file_uuid) {
    $file = $this->fileStorage
      ->loadByProperties([
      'uuid' => $file_uuid,
    ]);
    if ($file) {
      $values[] = [
        'target_id' => current($file)
          ->id(),
      ];
    }
  }
  return $values;
}