19 declare(strict_types=1);
29 protected \ilResourceStorageMigrationHelper
$helper;
33 return "Migration of booking object info files to the resource storage service.";
43 return \ilResourceStorageMigrationHelper::getPreconditions();
48 $this->helper = new \ilResourceStorageMigrationHelper(
56 $db = $this->helper->getDatabase();
57 $r = $this->helper->getDatabase()->query(
58 "SELECT booking_object_id, pool_id, owner FROM booking_object JOIN object_data ON pool_id = obj_id WHERE obj_info_rid IS NULL LIMIT 1;" 60 $d = $this->helper->getDatabase()->fetchObject(
$r);
61 $pool_id = (
int)
$d->pool_id;
62 $booking_object_id = (
int)
$d->booking_object_id;
63 $resource_owner_id = (
int)
$d->owner;
64 $base_path = $this->buildAbsolutPath($pool_id, $booking_object_id);
65 $pattern =
'/[^\.].*/m';
67 if (is_dir($base_path)) {
68 $rid = $this->helper->moveFirstFileOfPatternToStorage(
74 $this->helper->getDatabase()->update(
77 'obj_info_rid' => [
'text', (
string) $rid]
80 'booking_object_id' => [
'integer', $booking_object_id],
81 'pool_id' => [
'integer', $pool_id]
88 $r = $this->helper->getDatabase()->query(
89 "SELECT count(booking_object_id) amount FROM booking_object JOIN object_data ON pool_id = obj_id WHERE obj_info_rid IS NULL" 91 $d = $this->helper->getDatabase()->fetchObject(
$r);
93 return (
int)
$d->amount;
99 .
'/ilBookingManager/' buildAbsolutPath(int $pool_id, int $booking_object_id)
A migration is a potentially long lasting operation that can be broken into discrete steps...
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
step(Environment $environment)
Run one step of the migration.
static createPathFromId(int $a_container_id, string $a_name)
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
getPreconditions(Environment $environment)
Objectives the migration depend on.
An environment holds resources to be used in the setup process.
prepare(Environment $environment)
Prepare the migration by means of some environment.
ilResourceStorageMigrationHelper $helper