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; } }