exampleapp/modules/Tasks/Infrastructure/Storage/Factory.php

35 lines
1.1 KiB
PHP

<?php
namespace Modules\Tasks\Infrastructure\Storage;
use Modules\Tasks\Infrastructure\Factory as InfrastructureFactory;
use Modules\Tasks\Factory as ModuleFactory;
class Factory
{
private ?TasksStorage $tasksStorage = null;
private InfrastructureFactory $infFactory;
public function setInfrastructureFactory(InfrastructureFactory $factory): void
{
$this->infFactory = $factory;
}
public function getTasksStorage(): TasksStorage
{
if ($this->tasksStorage) {
return $this->tasksStorage;
}
$this->tasksStorage = new TasksStorage;
$tasksQuery = $this->infFactory->getDBQueriesFactory()->createTasksQuery();
$this->tasksStorage->setTasksQuery($tasksQuery);
$otherQuery = $this->infFactory->getOtherQueriesFactory()->createTasksQuery();
$this->tasksStorage->setOtherQuery($otherQuery);
// Если нам потребуется что-то из соседнего модуля, то:
// $otherModule = $this->infFactory->getModuleFactory()->getModulesProvider()->getOtherModule();
return $this->tasksStorage;
}
}