ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\LegalDocuments\Setup\UpdateSteps Class Reference
+ Inheritance diagram for ILIAS\LegalDocuments\Setup\UpdateSteps:
+ Collaboration diagram for ILIAS\LegalDocuments\Setup\UpdateSteps:

Public Member Functions

 prepare (ilDBInterface $database)
 
 step_1 ()
 
 step_2 ()
 
 step_3 ()
 
- Public Member Functions inherited from ilDatabaseUpdateSteps
 prepare (\ilDBInterface $db)
 Prepare the execution of the steps. More...
 

Protected Attributes

ilDBInterface $database
 

Private Member Functions

 ensureColumn (string $table, string $name, array $attributes)
 
 renameTables (array $tables)
 

Detailed Description

Definition at line 27 of file UpdateSteps.php.

Member Function Documentation

◆ ensureColumn()

ILIAS\LegalDocuments\Setup\UpdateSteps::ensureColumn ( string  $table,
string  $name,
array  $attributes 
)
private
Parameters
array<string,mixed>$attributes

Definition at line 90 of file UpdateSteps.php.

Referenced by ILIAS\LegalDocuments\Setup\UpdateSteps\step_1(), and ILIAS\LegalDocuments\Setup\UpdateSteps\step_3().

90  : void
91  {
92  if (!$this->database->tableColumnExists($table, $name)) {
93  $this->database->addTableColumn($table, $name, $attributes);
94  }
95  }
+ Here is the caller graph for this function:

◆ prepare()

ILIAS\LegalDocuments\Setup\UpdateSteps::prepare ( ilDBInterface  $database)

Definition at line 31 of file UpdateSteps.php.

31  : void
32  {
33  $this->database = $database;
34  }

◆ renameTables()

ILIAS\LegalDocuments\Setup\UpdateSteps::renameTables ( array  $tables)
private
Parameters
array<string|int,mixed>$tables

Definition at line 100 of file UpdateSteps.php.

Referenced by ILIAS\LegalDocuments\Setup\UpdateSteps\step_1().

100  : void
101  {
102  foreach ($tables as $old => $new) {
103  if (!$this->database->tableExists($new)) {
104  $this->database->renameTable($old, $new);
105  }
106  }
107  }
+ Here is the caller graph for this function:

◆ step_1()

ILIAS\LegalDocuments\Setup\UpdateSteps::step_1 ( )

Definition at line 36 of file UpdateSteps.php.

References ILIAS\LegalDocuments\Setup\UpdateSteps\ensureColumn(), ILIAS\LegalDocuments\Setup\UpdateSteps\renameTables(), and ilDBConstants\T_TEXT.

36  : void
37  {
38  $this->renameTables([
39  'tos_documents' => 'ldoc_documents',
40  'tos_criterion_to_doc' => 'ldoc_criteria',
41  'tos_acceptance_track' => 'ldoc_acceptance_track',
42  'tos_versions' => 'ldoc_versions',
43  ]);
44 
45  $this->ensureColumn('ldoc_documents', 'provider', [
46  'type' => ilDBConstants::T_TEXT,
47  'notnull' => true,
48  'default' => 'tos',
49  'length' => 255,
50  ]);
51 
52  $this->ensureColumn('ldoc_documents', 'hash', [
53  'type' => ilDBConstants::T_TEXT,
54  'notnull' => true,
55  'default' => '',
56  'length' => 255,
57  ]);
58 
59  foreach (['ldoc_documents', 'ldoc_versions'] as $table) {
60  $this->ensureColumn($table, 'type', [
61  'type' => ilDBConstants::T_TEXT,
62  'notnull' => true,
63  'default' => 'html',
64  'length' => 255,
65  ]);
66  }
67  }
ensureColumn(string $table, string $name, array $attributes)
Definition: UpdateSteps.php:90
+ Here is the call graph for this function:

◆ step_2()

ILIAS\LegalDocuments\Setup\UpdateSteps::step_2 ( )

Definition at line 69 of file UpdateSteps.php.

69  : void
70  {
71  // Keep
72  }

◆ step_3()

ILIAS\LegalDocuments\Setup\UpdateSteps::step_3 ( )

Definition at line 74 of file UpdateSteps.php.

References ILIAS\LegalDocuments\Setup\UpdateSteps\ensureColumn(), and ilDBConstants\T_TEXT.

74  : void
75  {
76  $this->ensureColumn('ldoc_versions', 'provider', [
77  'type' => ilDBConstants::T_TEXT,
78  'notnull' => true,
79  'default' => '',
80  'length' => 255,
81  ]);
82 
83  $select_provider = '(SELECT d.provider FROM ldoc_documents AS d WHERE v.doc_id = d.id)';
84  $this->database->manipulate("UPDATE ldoc_versions AS v SET provider = $select_provider WHERE provider = '' AND EXISTS $select_provider");
85  }
ensureColumn(string $table, string $name, array $attributes)
Definition: UpdateSteps.php:90
+ Here is the call graph for this function:

Field Documentation

◆ $database

ilDBInterface ILIAS\LegalDocuments\Setup\UpdateSteps::$database
protected

Definition at line 29 of file UpdateSteps.php.


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