<?php

namespace App\Models\Pages;

use App\Models\Factory as ModelsFactory;
use App\Providers\AppServiceProvider;
use Modules\ModulesProvider;

class Factory
{

    private ModelsFactory $modelsFactory;

    public function setModelsFactory(ModelsFactory $factory): void
    {
        $this->modelsFactory = $factory;
    }

    public function createMainInfoPage(): MainInfo
    {
        $page = new MainInfo;
        /** @var ModulesProvider */
        $modulesProvider = app()->get(AppServiceProvider::ADMIN_MODULES);
        $itemsStorage = $modulesProvider->getJsonObjectsFactory()->getInfrastructureFactory()->getStorage();
        $page->setItemsStorage($itemsStorage);
        $itemFactory = $modulesProvider->getJsonObjectsFactory()->getDtoFactory()->getItemFactory();
        $page->setItemFactory($itemFactory);
        $page->init();
        return $page;
    }
}
