You are here

protected function Event::prepareAttachment in Open Social 8

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

Returns reference to attachment, possibly with a description.

Parameters

array $files: Array with UUIDs of files.

Return value

array|null Array containing related files or NULL.

1 call to Event::prepareAttachment()
Event::getEntry in modules/custom/social_demo/src/Plugin/DemoContent/Event.php
Makes an array with data of an entity.

File

modules/custom/social_demo/src/Plugin/DemoContent/Event.php, line 149

Class

Event
Event Plugin for demo content.

Namespace

Drupal\social_demo\Plugin\DemoContent

Code

protected function prepareAttachment(array $files) {
  $attachments = NULL;
  foreach ($files as $file) {
    $description = '';

    // If it is an array, this means we also have a description.
    if (is_array($file)) {
      $uuid = key($file);
      $description = current($file);
    }
    else {
      $uuid = $file;
    }
    $object = $this->fileStorage
      ->loadByProperties([
      'uuid' => $uuid,
    ]);
    if ($object) {
      $properties = [
        'target_id' => current($object)
          ->id(),
        'description' => $description,
      ];
      $attachments[] = $properties;
    }
  }
  return $attachments;
}