*/
public static function getData($item)
{
- if ($item['backend-class'] == '') {
+ $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
+ if ($backendClass === null) {
// legacy data storage in 'data' column
$i = self::selectFirst(['data'], ['id' => $item['id']]);
if ($i === false) {
}
return $i['data'];
} else {
- $backendClass = $item['backend-class'];
$backendRef = $item['backend-ref'];
- return $backendClass::get($backendRef);
+ return $backendClass->get($backendRef);
}
}
foreach($items as $item) {
$backend_class = DI::storageManager()->getByName($item['backend-class'] ?? '');
- if ($backend_class !== '') {
+ if ($backend_class !== null) {
$fields['backend-ref'] = $backend_class->put($img->asString(), $item['backend-ref'] ?? '');
} else {
$fields['data'] = $img->asString();
*/
public static function getImageForPhoto(array $photo)
{
- if (empty($photo['backend-class'])) {
+ $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
+ if ($backendClass === null) {
// legacy data storage in "data" column
$i = self::selectFirst(['data'], ['id' => $photo['id']]);
if ($i === false) {
}
$data = $i['data'];
} else {
- $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
$backendRef = $photo['backend-ref'] ?? '';
$data = $backendClass->get($backendRef);
}