ILIAS  release_8 Revision v8.24
ilObjCloudModuleMigration.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
7
25{
26 protected ilDBInterface $db;
27
28 public function getLabel(): string
29 {
30 return 'ilObjCloudModule Data Removal. Attention, this deletes all Data of the Cloud Module from the Repository';
31 }
32
34 {
35 return Migration::INFINITE;
36 }
37
38 public function getRemainingAmountOfSteps(): int
39 {
40 if ($this->db->fetchObject($this->getCloudReferencesQuery())) {
41 return 1;
42 } else {
43 return 0;
44 }
45 }
46
50 public function getPreconditions(Environment $environment): array
51 {
52 return [
55 ];
56 }
57
58 public function prepare(Environment $environment): void
59 {
60 //This is necessary for using ilObjects delete function to remove existing objects
63 $this->db = $environment->getResource(Environment::RESOURCE_DATABASE);
64 }
65
66 public function step(Environment $environment): void
67 {
68 while ($result = $this->db->fetchObject($this->getCloudReferencesQuery())) {
69 $cloud_object = new ilObjCloud((int) $result->ref_id);
70 $cloud_object->delete();
71 }
72 }
73
75 {
76 return $this->db->query("
77 SELECT ref_id
78 FROM object_data, object_reference
79 WHERE object_data.type = 'cld' AND object_data.obj_id = object_reference.obj_id");
80 }
81}
const CONTEXT_CRON
static init(string $a_type)
Init context by type.
static initILIAS()
ilias initialisation
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
getPreconditions(Environment $environment)
step(Environment $environment)
Run one step of the migration.
prepare(Environment $environment)
Prepare the migration by means of some environment.
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
A migration is a potentially long lasting operation that can be broken into discrete steps.
Definition: Migration.php:29
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...