Skip to content

Commit

Permalink
[import] mg frontend flags
Browse files Browse the repository at this point in the history
  • Loading branch information
rastislav-chynoransky committed Jan 22, 2024
1 parent bd52182 commit 7101238
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Enums/FrontendEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
enum FrontendEnum: string
{
case WEBUMENIA = 'webumenia';
case MORAVSKA_GALERIE = 'moravska-galerie';
}
27 changes: 27 additions & 0 deletions app/Importers/MgImporterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

namespace App\Importers;

use App\Enums\FrontendEnum;
use App\ImportRecord;
use App\Item;
use App\ItemFrontend;

trait MgImporterTrait
{
protected array $mediumTranslationKeys;
Expand All @@ -25,6 +30,28 @@ protected function init(): void
$this->topicTranslationKeys = array_flip(trans('item.topics', locale: 'cs'));
}

protected function importSingle(array $record, ImportRecord $import_record): ?Item
{
$image_filename_format = $this->getItemImageFilenameFormat($record);
$files = $this->getJp2Files($import_record, $image_filename_format);

$item = parent::importSingle($record, $import_record);

$item->frontends()->delete();
$item->frontends->push(ItemFrontend::make([
'frontend' => FrontendEnum::MORAVSKA_GALERIE,
'item_id' => $item->id,
]));
if (!$files->isEmpty()) {
$item->frontends->push(ItemFrontend::make([
'frontend' => FrontendEnum::WEBUMENIA,
'item_id' => $item->id,
]));
}

return $item;
}

protected function getItemId(array $record): string
{
$id = sprintf('CZE:MG.%s_%s', $record['Rada_S'], (int) $record['PorC_S']);
Expand Down

0 comments on commit 7101238

Please sign in to comment.