41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\Tasks\Application;
|
|
|
|
use Modules\Tasks\Factory as ModuleFactory;
|
|
|
|
class Factory
|
|
{
|
|
|
|
private ModuleFactory $moduleFactory;
|
|
|
|
private ?Api $api = null;
|
|
|
|
public function setModuleFactory(ModuleFactory $moduleFactory): void
|
|
{
|
|
$this->moduleFactory = $moduleFactory;
|
|
}
|
|
|
|
private function createValidator(): Validator
|
|
{
|
|
return new Validator();
|
|
}
|
|
|
|
public function getApi(): Api
|
|
{
|
|
if ($this->api) {
|
|
return $this->api;
|
|
}
|
|
$this->api = new Api();
|
|
$validator = $this->createValidator();
|
|
$this->api->setValidator($validator);
|
|
$tasksStorage = $this->moduleFactory->getInfrastructureFactory()->getStorageFactory()->getTasksStorage();
|
|
$this->api->setTasksStorage($tasksStorage);
|
|
$dtoFactory = $this->moduleFactory->getDtoFactory();
|
|
$this->api->setDtoFactory($dtoFactory);
|
|
$tasksLayer = $this->moduleFactory->getInfrastructureFactory()->getDBPersistLayerFactory()->getTasksLayer();
|
|
$this->api->setTasksLayer($tasksLayer);
|
|
return $this->api;
|
|
}
|
|
}
|