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;
  }
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;
  }
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 ; }
Returns reference to attachment, possibly with a description.

@param array $files
Array with UUIDs of files.

@return array|null
Array containing related files or NULL.
Returns reference to attachment possibly with a description .