35 lines
962 B
PHP
35 lines
962 B
PHP
|
|
<?php namespace Lucent\Core\File;
|
||
|
|
|
||
|
|
use Lucent\Core\Data\RecordFile;
|
||
|
|
use Lucent\Core\Data\RecordMode;
|
||
|
|
use stdClass;
|
||
|
|
|
||
|
|
class RecordFileModule
|
||
|
|
{
|
||
|
|
public static function toDb(RecordFile $file): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
"id" => $file->id,
|
||
|
|
"record_id" => $file->recordId,
|
||
|
|
"file_id" => $file->fileId,
|
||
|
|
"field_id" => $file->fieldId,
|
||
|
|
"mode" => $file->mode,
|
||
|
|
"locale" => $file->locale,
|
||
|
|
"rank" => $file->rank,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function fromDb(stdClass $data): RecordFile
|
||
|
|
{
|
||
|
|
return new RecordFile(
|
||
|
|
id: data_get($data, "id"),
|
||
|
|
recordId: data_get($data, "recordId"),
|
||
|
|
fileId: data_get($data, "file_id"),
|
||
|
|
fieldId: data_get($data, "field_id"),
|
||
|
|
mode: RecordMode::from(data_get($data, "mode")),
|
||
|
|
locale: data_get($data, "locale"),
|
||
|
|
rank: data_get($data, "rank"),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|