19declare(strict_types=1);
31 return 'Migration of Media Objects to the Resource Storage Service.';
54 $r = $this->helper->getDatabase()->query(
55 "SELECT * FROM object_data od LEFT JOIN mob_data md ON (od.obj_id = md.id) WHERE od.type='mob' AND (rid='' OR rid IS NULL) LIMIT 1;"
58 $d = $this->helper->getDatabase()->fetchObject($r);
59 $object_id = (
int) (
$d->obj_id ??
null);
61 $resource_owner_id = (
int) (
$d->owner_id ?? 6);
65 $rid = $this->helper->moveDirectoryToContainerResource(
71 $this->helper->getDatabase()->replace(
74 "id" => [
"integer", $object_id]
77 "rid" => [
"text", $rid->serialize()]
83 $this->helper->getDatabase()->replace(
86 "id" => [
"integer", $object_id]
89 "rid" => [
"text",
"-"]
98 $files = array_diff(scandir(
$path), [
'.',
'..']);
99 foreach ($files as $file) {
100 (is_dir(
"$path/$file")) ? $this->
recursiveRmDir(
"$path/$file") : unlink(
"$path/$file");
106 $r = $this->helper->getDatabase()->query(
107 "SELECT COUNT(od.obj_id) amount FROM object_data od LEFT JOIN mob_data md ON (od.obj_id = md.id) WHERE od.type='mob' AND (rid='' OR rid IS NULL)"
109 $d = $this->helper->getDatabase()->fetchObject($r) ??
new stdClass();
110 return (
int) (
$d->amount ?? 0);
120 return static function (
string $file_name) use ($pattern):
string {
121 if (preg_match($pattern, $file_name, $matches)) {
122 return $matches[1] ?? $file_name;
130 return static function (
string $file_name):
string {
131 return md5($file_name);
Class ResourceCollection.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
buildBasePath(int $object_id)
step(Environment $environment)
Run one step of the migration.
getRevisionNameCallback()
getPreconditions(Environment $environment)
Objectives the migration depend on.
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
recursiveRmDir(string $path)
ilResourceStorageMigrationHelper $helper
getFileNameCallback(string $pattern)
prepare(Environment $environment)
Prepare the migration by means of some environment.
Class ilResourceStorageMigrationHelper.
static getPreconditions()
An environment holds resources to be used in the setup process.
A migration is a potentially long lasting operation that can be broken into discrete steps.