ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ilMobLastChangeMigration Class Reference
+ Inheritance diagram for ilMobLastChangeMigration:
+ Collaboration diagram for ilMobLastChangeMigration:

Public Member Functions

 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 
 getLabel ()
 
 getDefaultAmountOfStepsPerRun ()
 Tell the default amount of steps to be executed for one run of the migration. More...
 
 getPreconditions (Environment $environment)
 Objectives the migration depend on. More...
 
 prepare (Environment $environment)
 Prepare the migration by means of some environment. More...
 
 step (Environment $environment)
 Run one step of the migration. More...
 
 getRemainingAmountOfSteps ()
 Count up how many "things" need to be migrated. More...
 

Protected Attributes

ilDBInterface $db
 

Additional Inherited Members

- Data Fields inherited from ILIAS\Setup\Migration
const INFINITE = -1
 

Detailed Description

Definition at line 24 of file class.ilMobLastChangeMigration.php.

Member Function Documentation

◆ getDefaultAmountOfStepsPerRun()

ilMobLastChangeMigration::getDefaultAmountOfStepsPerRun ( )

Tell the default amount of steps to be executed for one run of the migration.

Return Migration::INFINITE if all units should be migrated at once.

Implements ILIAS\Setup\Migration.

Definition at line 33 of file class.ilMobLastChangeMigration.php.

33 : int
34 {
35 return 10000;
36 }

◆ getLabel()

ilMobLastChangeMigration::getLabel ( )
Returns
string - a meaningful and concise description for your migration.

Implements ILIAS\Setup\Migration.

Definition at line 28 of file class.ilMobLastChangeMigration.php.

28 : string
29 {
30 return 'Migration for setting date of last change of existing media objects to their creation date.';
31 }

◆ getPreconditions()

ilMobLastChangeMigration::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 38 of file class.ilMobLastChangeMigration.php.

38 : array
39 {
40 return [
41 new \ilDatabaseInitializedObjective(),
42 new \ilDatabaseUpdatedObjective()
43 ];
44 }

◆ getRemainingAmountOfSteps()

ilMobLastChangeMigration::getRemainingAmountOfSteps ( )

Count up how many "things" need to be migrated.

This helps the admin to decide how big he can create the steps and also how long a migration takes

Implements ILIAS\Setup\Migration.

Definition at line 71 of file class.ilMobLastChangeMigration.php.

71 : int
72 {
73 $res = $this->db->query(
74 "SELECT COUNT(mob_data.id) AS count FROM mob_data JOIN object_data ON object_data.obj_id = mob_data.id" .
75 " WHERE last_change = 0"
76 );
77 if ($row = $this->db->fetchAssoc($res)) {
78 return $row['count'] ?? 0;
79 }
80 return 0;
81 }
$res
Definition: ltiservices.php:69

References $res.

◆ prepare()

ilMobLastChangeMigration::prepare ( Environment  $environment)

Prepare the migration by means of some environment.

This is not supposed to modify the environment, but will be run to prime the migration object to run step and getRemainingAmountOfSteps afterwards.

Implements ILIAS\Setup\Migration.

Definition at line 46 of file class.ilMobLastChangeMigration.php.

46 : void
47 {
48 $this->db = $environment->getResource(Environment::RESOURCE_DATABASE);
49 }
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.

References ILIAS\Setup\Environment\getResource().

+ Here is the call graph for this function:

◆ step()

ilMobLastChangeMigration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 51 of file class.ilMobLastChangeMigration.php.

51 : void
52 {
53 $res = $this->db->query(
54 "SELECT mob_data.id AS mob_id, object_data.create_date AS date FROM mob_data" .
55 " LEFT JOIN object_data ON object_data.obj_id = mob_data.id" .
56 " WHERE last_change = 0 ORDER BY mob_id LIMIT 1"
57 );
58 if (!($row = $this->db->fetchAssoc($res))) {
59 return;
60 }
61 $mob_id = (int) $row['mob_id'];
62 $date = new DateTimeImmutable((string) $row['date']);
63
64 $this->db->update(
65 'mob_data',
66 ['last_change' => ['integer', $date->getTimestamp()]],
67 ['id' => ['integer', $mob_id]]
68 );
69 }

References $res, and ILIAS\Repository\int().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilMobLastChangeMigration::$db
protected

Definition at line 26 of file class.ilMobLastChangeMigration.php.


The documentation for this class was generated from the following file: