protected function Topic::prepareAttachment in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareAttachment()
- 8 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareAttachment()
- 8.2 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareAttachment()
- 8.3 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareAttachment()
- 8.4 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareAttachment()
- 8.5 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareAttachment()
- 8.6 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareAttachment()
- 8.7 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareAttachment()
- 10.3.x modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareAttachment()
- 10.0.x modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareAttachment()
- 10.1.x modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareAttachment()
- 10.2.x modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::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 Topic::prepareAttachment()
- Topic::getEntry in modules/
custom/ social_demo/ src/ Plugin/ DemoContent/ Topic.php - Makes an array with data of an entity.
File
- modules/
custom/ social_demo/ src/ Plugin/ DemoContent/ Topic.php, line 99
Class
- Topic
- Topic Plugin for demo content.
Namespace
Drupal\social_demo\Plugin\DemoContentCode
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;
}