disk = $disk; } /** * 카테고리와 경로를 조합하여 전체 경로를 생성합니다. * * @param string $category 카테고리 (빈 문자열이면 경로만 사용) * @param string $path 상대 경로 * @return string 전체 경로 ({category}/{path} 또는 {path}) */ private function resolvePath(string $category, string $path): string { if (empty($category)) { return $path; } if (empty($path)) { return $category; } return "{$category}/{$path}"; } /** * {@inheritDoc} */ public function put(string $category, string $path, mixed $content): bool { $fullPath = $this->resolvePath($category, $path); return Storage::disk($this->disk)->put($fullPath, $content); } /** * {@inheritDoc} */ public function get(string $category, string $path): ?string { $fullPath = $this->resolvePath($category, $path); if (! Storage::disk($this->disk)->exists($fullPath)) { return null; } return Storage::disk($this->disk)->get($fullPath); } /** * {@inheritDoc} */ public function exists(string $category, string $path): bool { $fullPath = $this->resolvePath($category, $path); return Storage::disk($this->disk)->exists($fullPath); } /** * {@inheritDoc} */ public function delete(string $category, string $path): bool { $fullPath = $this->resolvePath($category, $path); return Storage::disk($this->disk)->delete($fullPath); } /** * `core.storage.filter_url` 훅 컨텍스트의 드라이버별 식별 정보를 반환합니다. * * @return array{scope: string, identifier: ?string} scope + 식별자 (코어는 null) */ protected function urlHookContext(): array { return [ 'scope' => 'core', 'identifier' => null, ]; } /** * {@inheritDoc} */ public function files(string $category, string $directory = ''): array { $fullPath = $this->resolvePath($category, $directory); return Storage::disk($this->disk)->files($fullPath); } /** * {@inheritDoc} */ public function deleteDirectory(string $category, string $directory = ''): bool { $fullPath = $this->resolvePath($category, $directory); return Storage::disk($this->disk)->deleteDirectory($fullPath); } /** * {@inheritDoc} */ public function getBasePath(string $category): string { $fullPath = $this->resolvePath($category, ''); return Storage::disk($this->disk)->path($fullPath); } /** * {@inheritDoc} */ public function getDisk(): string { return $this->disk; } /** * {@inheritDoc} */ public function deleteAll(string $category): bool { return $this->deleteDirectory($category, ''); } /** * {@inheritDoc} */ public function response(string $category, string $path, string $filename, array $headers = []): ?StreamedResponse { $fullPath = $this->resolvePath($category, $path); if (! Storage::disk($this->disk)->exists($fullPath)) { return null; } return Storage::disk($this->disk)->response($fullPath, $filename, $headers); } /** * {@inheritDoc} */ public function withDisk(string $disk): static { $clone = clone $this; $clone->disk = $disk; return $clone; } /** * {@inheritDoc} */ public function download(string $category, string $path, string $filename, array $headers = []): ?StreamedResponse { $fullPath = $this->resolvePath($category, $path); if (! Storage::disk($this->disk)->exists($fullPath)) { return null; } return Storage::disk($this->disk)->download($fullPath, $filename, $headers); } }