fileSystemId = $id; $this->prefix = $this->sanitizePath($prefix); } /** * Get id * * @return mixed */ public function getFileSystemId() { return $this->fileSystemId; } /** * Return the prefix e.q. key of file system * * @return string */ public function getPrefix() { return $this->prefix; } /** * Get current base directory * * @return FileSystem */ protected function getBaseDirectory() { if (! $this->fileSystem) { $this->fileSystem = $this->getServiceLocator() ->get(FileSystemService::SERVICE_ID) ->getDirectory($this->getFileSystemId()); } return $this->fileSystem; } /** * Get current fileystem * * @return FileSystem */ public function getFileSystem() { if (! $this->fileSystem) { $this->fileSystem = $this->getServiceLocator() ->get(FileSystemService::SERVICE_ID) ->getFileSystem($this->getFileSystemId()); } return $this->fileSystem; } /** * Sanitize path: * - by replace \ to / for windows compatibility * - trim . * - trim / or \\ * * @param $path * @return string */ protected function sanitizePath($path) { $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); $path = preg_replace('/' . preg_quote('./', '/') . '/', '', $path, 1); $path = trim($path, '/'); return $path; } }