1 <?php declare(strict_types=1);
53 $existing_handler = $this->handler_factory->getHandlerForResource($resource);
54 $existing_path = $this->filesystem_base_path .
'/' . $existing_handler->getFullContainerPath($resource->
getIdentification());
56 $new_handler = $this->handler_factory->getHandlerForStorageId($to_handler_id);
57 $destination_path = $this->filesystem_base_path .
'/' . $new_handler->getFullContainerPath($resource->
getIdentification());
59 if (!file_exists($existing_path)) {
61 $this->resource_builder->remove($resource);
65 if (!is_dir(dirname($destination_path))) {
66 if (!mkdir(dirname($destination_path), 0777,
true)) {
70 if (rename($existing_path, $destination_path)) {
71 $r = $this->database->manipulateF(
72 "UPDATE il_resource SET storage_id = %s WHERE rid = %s LIMIT 1",
78 if ($this->clean_up) {
79 $existing_handler->cleanUpContainer($resource);
90 foreach (glob($path . DIRECTORY_SEPARATOR .
"*") as $file) {
93 return $empty && rmdir($path);
migrate(StorableResource $resource, string $to_handler_id)
Interface StorageResource.
removeEmptySubFolders($path)
__construct(StorageHandlerFactory $handler_factory, ResourceBuilder $resource_builder, \ilDBInterface $database, string $filesystem_base_path)
Migrator constructor.
Class StorageHandlerFactory.