designtopack/public/site/plugins/helpers/index.php
2024-11-28 14:45:45 +01:00

23 lines
No EOL
617 B
PHP

<?php
function getFileData($file) {
$data = [
'modified' => $file->modified('YYYY-MM-dd'),
'url' => $file->url(),
'uuid' => (string) $file->uuid(),
'name' => $file->filename(),
'label' => (string) $file->label(),
'type' => (string) $file->type(),
];
if ($file->description()->exists()) {
$data['description'] = $file->description()->value();
$data['tags'] = $file->tags()->split();
};
if($file->extension() == "pdf") {
$data['comments'] = $file->comments()->exists() && $file->comments() ? Data::decode($file->comments()->value(), 'yaml') : [];
}
return $data;
}