laravel12_start/app/Models/Pages/MainInfo.php

42 lines
1016 B
PHP

<?php
namespace App\Models\Pages;
use App\Models\Factory as ModelsFactory;
use Src\Modules\JsonObjects\Interfaces\Infrastructure\IItemStorage;
use Src\Modules\JsonObjects\Interfaces\Dto\Item\IFactory as IItemFactory;
use Modules\Objects\MainInfo as MainInfoObject;
class MainInfo
{
private IItemStorage $itemsStorage;
private IItemFactory $itemFactory;
private MainInfoObject $mainInfoObject;
public function setItemsStorage(IItemStorage $storage): void
{
$this->itemsStorage = $storage;
}
public function setItemFactory(IItemFactory $factory): void
{
$this->itemFactory = $factory;
}
public function init(): void
{
$mainInfoData = $this->itemsStorage->getByKey('main_info');
$mainInfo = $this->itemFactory->createResource();
$mainInfo->load($mainInfoData);
$this->mainInfoObject = $mainInfo->getObject();
}
public function getMainInfo(): MainInfoObject
{
return $this->mainInfoObject;
}
}