65 public function __construct($a_storage_type, $a_path_conversion, $a_container_id)
67 $this->storage_type = $a_storage_type;
68 $this->path_conversion = $a_path_conversion;
69 $this->container_id = $a_container_id;
98 return $stream->getMetadata(
'uri');
109 case self::STORAGE_DATA:
110 return $DIC->filesystem()->storage();
112 case self::STORAGE_WEB:
113 case self::SECURED_DIRECTORY:
114 return $DIC->filesystem()->web();
138 $num = $a_container_id;
140 for (
$i = self::MAX_EXPONENT;
$i > 0;
$i--) {
141 $factor = pow(self::FACTOR,
$i);
142 if (($tmp = (
int) ($num / $factor))
or $found) {
144 $num = $num % $factor;
150 $path_string = (implode(
'/',
$path) .
'/');
153 return $path_string . $a_name .
'_' . $a_container_id;
240 switch ($this->storage_type) {
241 case self::STORAGE_DATA:
242 case self::STORAGE_WEB:
244 case self::STORAGE_SECURED:
245 $this->path .=
'/' . self::SECURED_DIRECTORY;
252 if ($this->path_conversion) {
253 $this->path .= self::_createPathFromId($this->container_id, $this->
getPathPostfix());
324 public function delete()
367 $sourceFS = LegacyPathHelper::deriveFilesystemFrom($a_sdir);
368 $targetFS = LegacyPathHelper::deriveFilesystemFrom($a_tdir);
370 $sourceDir = LegacyPathHelper::createRelativePath($a_sdir);
371 $targetDir = LegacyPathHelper::createRelativePath($a_tdir);
378 $sourceList = $sourceFS->listContents(
$sourceDir,
true);
380 foreach ($sourceList as $item) {
381 if ($item->isDir()) {
385 $itemPath = $targetDir .
'/' . substr($item->getPath(), strlen(
$sourceDir));
387 $targetFS->writeStream($itemPath, $stream);
402 $this->path .= $a_appendix;
433 return $relative_path;
getPathPostfix()
Get directory name.
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
fileExists($a_absolute_path)
getLegacyFullAbsolutePath($relative_path)
$stream
PHP stream implementation.
create()
Create directory.
getPathPrefix()
Get path prefix.
writeToFile($a_data, $a_absolute_path)
__construct($a_storage_type, $a_path_conversion, $a_container_id)
Constructor.
getLegacyAbsolutePath()
Calculates the absolute filesystem storage location.
appendToPath($a_appendix)
static _copyDirectory($a_sdir, $a_tdir)
getAbsolutePath()
Calculates the full path on the filesystem.
deleteDirectory($a_absolute_path)
deleteFile($a_absolute_path)
createRelativePathForFileSystem($a_absolute_path)
static _createPathFromId($a_container_id, $a_name)
Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.