ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilContentStyle9Migration Class Reference
+ Inheritance diagram for ilContentStyle9Migration:
+ Collaboration diagram for ilContentStyle9Migration:

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

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

Member Function Documentation

◆ getDefaultAmountOfStepsPerRun()

ilContentStyle9Migration::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.ilContentStyle9Migration.php.

33  : int
34  {
35  return 50000;
36  }

◆ getLabel()

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

Implements ILIAS\Setup\Migration.

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

28  : string
29  {
30  return "Migrate content styles to ILIAS 9.";
31  }

◆ getPreconditions()

ilContentStyle9Migration::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.ilContentStyle9Migration.php.

◆ getRemainingAmountOfSteps()

ilContentStyle9Migration::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 117 of file class.ilContentStyle9Migration.php.

117  : int
118  {
119  $set = $this->db->queryF(
120  "SELECT count(*) as amount FROM style_parameter " .
121  " WHERE type = %s AND tag = %s",
122  ["text", "text"],
123  ["text_block", "div"]
124  );
125  if ($rec = $this->db->fetchAssoc($set)) {
126  return (int) $rec["amount"];
127  }
128 
129  return 0;
130  }

◆ prepare()

ilContentStyle9Migration::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 48 of file class.ilContentStyle9Migration.php.

References ILIAS\Setup\Environment\getResource().

48  : void
49  {
50  $this->db = $environment->getResource(Environment::RESOURCE_DATABASE);
51  /*
52  $ilias_ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
53  $client_id = $environment->getResource(Environment::RESOURCE_CLIENT_ID);
54  $data_dir = $ilias_ini->readVariable('clients', 'datadir');
55  $client_data_dir = "{$data_dir}/{$client_id}";
56  if (!defined("CLIENT_WEB_DIR")) {
57  define("CLIENT_WEB_DIR", dirname(__DIR__, 4) . "/data/" . $client_id);
58  }
59  if (!defined("ILIAS_WEB_DIR")) {
60  define("ILIAS_WEB_DIR", dirname(__DIR__, 4));
61  }
62  if (!defined("CLIENT_ID")) {
63  define("CLIENT_ID", $client_id);
64  }
65  if (!defined("ILIAS_DATA_DIR")) {
66  define("ILIAS_DATA_DIR", $data_dir);
67  }*/
68  }
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
+ Here is the call graph for this function:

◆ step()

ilContentStyle9Migration::step ( Environment  $environment)

Run one step of the migration.

Implements ILIAS\Setup\Migration.

Definition at line 70 of file class.ilContentStyle9Migration.php.

70  : void
71  {
72  $set = $this->db->queryF(
73  "SELECT * FROM style_parameter " .
74  " WHERE type = %s AND tag = %s LIMIT 1",
75  ["text", "text"],
76  ["text_block", "div"]
77  );
78  if ($rec = $this->db->fetchAssoc($set)) {
79  // check, if a similar parameter is not already been set
80  $set2 = $this->db->queryF(
81  "SELECT * FROM style_parameter " .
82  " WHERE style_id = %s AND tag = %s AND class = %s AND type = %s AND parameter = %s",
83  ["integer", "text", "text", "text", "text"],
84  [$rec["style_id"], "p", $rec["class"], "text_block", $rec["parameter"]]
85  );
86  if (!$this->db->fetchAssoc($set2)) {
87  $this->db->update(
88  "style_parameter",
89  [
90  "tag" => ["text", "p"]
91  ],
92  [ // where
93  "id" => ["integer", $rec["id"]]
94  ]
95  );
96 
97  $this->db->update(
98  "style_data",
99  [
100  "uptodate" => ["integer", 0]
101  ],
102  [ // where
103  "id" => ["integer", $rec["style_id"]]
104  ]
105  );
106  } else {
107  $this->db->manipulateF(
108  "DELETE FROM style_parameter WHERE " .
109  " id = %s",
110  ["integer"],
111  [$rec["id"]]
112  );
113  }
114  }
115  }

Field Documentation

◆ $db

ilDBInterface ilContentStyle9Migration::$db
protected

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


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