implementationClassNameMap = $implementationClassNameMap; $this->injectableFactory = $injectableFactory; } private function getImplementation(?string $storage = null) { if (!$storage) { $storage = 'EspoUploadDir'; } if (!array_key_exists($storage, $this->implementations)) { if (!array_key_exists($storage, $this->implementationClassNameMap)) { throw new Error("FileStorageManager: Unknown storage '{$storage}'"); } $className = $this->implementationClassNameMap[$storage]; $this->implementations[$storage] = $this->injectableFactory->create($className); } return $this->implementations[$storage]; } public function isFile(Attachment $attachment) : bool { $implementation = $this->getImplementation($attachment->get('storage')); return $implementation->isFile($attachment); } public function getContents(Attachment $attachment) { $implementation = $this->getImplementation($attachment->get('storage')); return $implementation->getContents($attachment); } public function putContents(Attachment $attachment, $contents) { $implementation = $this->getImplementation($attachment->get('storage')); return $implementation->putContents($attachment, $contents); } public function unlink(Attachment $attachment) { $implementation = $this->getImplementation($attachment->get('storage')); return $implementation->unlink($attachment); } public function getLocalFilePath(Attachment $attachment) : string { $implementation = $this->getImplementation($attachment->get('storage')); return $implementation->getLocalFilePath($attachment); } public function hasDownloadUrl(Attachment $attachment) : bool { $implementation = $this->getImplementation($attachment->get('storage')); return $implementation->hasDownloadUrl($attachment); } public function getDownloadUrl(Attachment $attachment) : string { $implementation = $this->getImplementation($attachment->get('storage')); return $implementation->getDownloadUrl($attachment); } }