ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
ILIAS\ILIASObject\Setup\MigrateTranslations Class Reference
+ Inheritance diagram for ILIAS\ILIASObject\Setup\MigrateTranslations:
+ Collaboration diagram for ILIAS\ILIASObject\Setup\MigrateTranslations:

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...
 

Private Attributes

const TESTS_PER_STEP = 100
 
ilDBInterface $db
 

Additional Inherited Members

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

Detailed Description

Definition at line 27 of file MigrateTranslations.php.

Member Function Documentation

◆ getDefaultAmountOfStepsPerRun()

ILIAS\ILIASObject\Setup\MigrateTranslations::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 38 of file MigrateTranslations.php.

38  : int
39  {
40  return 1;
41  }

◆ getLabel()

ILIAS\ILIASObject\Setup\MigrateTranslations::getLabel ( )
Returns
string - a meaningful and concise description for your migration.

Implements ILIAS\Setup\Migration.

Definition at line 33 of file MigrateTranslations.php.

33  : string
34  {
35  return 'Remove Table for Content Translation Information & Move Information to Translations';
36  }

◆ getPreconditions()

ILIAS\ILIASObject\Setup\MigrateTranslations::getPreconditions ( Environment  $environment)

Objectives the migration depend on.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Migration.

Definition at line 43 of file MigrateTranslations.php.

43  : array
44  {
45  return [
46  new \ilDatabaseInitializedObjective()
47  ];
48  }

◆ getRemainingAmountOfSteps()

ILIAS\ILIASObject\Setup\MigrateTranslations::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 106 of file MigrateTranslations.php.

Referenced by ILIAS\ILIASObject\Setup\MigrateTranslations\step().

106  : int
107  {
108  if (!$this->db->tableExists('obj_content_master_lng')) {
109  return 0;
110  }
111 
112  $drop_table_steps = 0;
113  if ($this->db->tableExists('obj_content_master_lng')) {
114  $drop_table_steps = 1;
115  }
116 
117  return ((int) ceil(
118  $this->db->fetchObject(
119  $this->db->query('
120  SELECT DISTINCT COUNT(obj_id) as cnt
121  FROM obj_content_master_lng
122  ')
123  )->cnt / self::TESTS_PER_STEP
124  )) + $drop_table_steps;
125  }
+ Here is the caller graph for this function:

◆ prepare()

ILIAS\ILIASObject\Setup\MigrateTranslations::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 50 of file MigrateTranslations.php.

References ILIAS\Setup\Environment\getResource(), and ILIAS\Setup\Environment\RESOURCE_DATABASE.

50  : void
51  {
52  $this->db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
53  }
+ Here is the call graph for this function:

◆ step()

ILIAS\ILIASObject\Setup\MigrateTranslations::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 55 of file MigrateTranslations.php.

References ILIAS\ILIASObject\Setup\MigrateTranslations\getRemainingAmountOfSteps(), null, ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

55  : void
56  {
57  if (!$this->db->tableExists('obj_content_master_lng')) {
58  return;
59  }
60  $query_result = $this->db->query(
61  'SELECT obj_id, master_lang, fallback_lang FROM obj_content_master_lng LIMIT ' . self::TESTS_PER_STEP
62  );
63 
64  while (($row = $this->db->fetchObject($query_result)) !== null) {
65  $this->db->update(
66  'object_translation',
67  [
68  'lang_base' => [\ilDBConstants::T_INTEGER, 1]
69  ],
70  [
71  'obj_id' => [\ilDBConstants::T_INTEGER, $row->obj_id],
72  'lang_code' => [\ilDBConstants::T_TEXT, $row->master_lang]
73  ]
74  );
75  if ($row->fallback_lang !== null && $row->fallback_lang !== '') {
76  $this->db->update(
77  'object_translation',
78  [
79  'lang_default' => [\ilDBConstants::T_INTEGER, 0]
80  ],
81  [
82  'obj_id' => [\ilDBConstants::T_INTEGER, $row->obj_id]
83  ]
84  );
85  $this->db->update(
86  'object_translation',
87  [
88  'lang_default' => [\ilDBConstants::T_INTEGER, 1]
89  ],
90  [
91  'obj_id' => [\ilDBConstants::T_INTEGER, $row->obj_id],
92  'lang_code' => [\ilDBConstants::T_TEXT, $row->fallback_lang]
93  ]
94  );
95  }
96  $this->db->manipulate(
97  "DELETE FROM obj_content_master_lng WHERE obj_id = {$row->obj_id}"
98  );
99  }
100 
101  if ($this->getRemainingAmountOfSteps() === 1) {
102  $this->db->dropTable('obj_content_master_lng');
103  }
104  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ILIAS\ILIASObject\Setup\MigrateTranslations::$db
private

Definition at line 31 of file MigrateTranslations.php.

◆ TESTS_PER_STEP

const ILIAS\ILIASObject\Setup\MigrateTranslations::TESTS_PER_STEP = 100
private

Definition at line 29 of file MigrateTranslations.php.


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