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

Public Member Functions

 prepare (ilDBInterface $db)
 
 step_1 ()
 Adds a new table column called 'has_language_limitation' which is used to define whether a notification is only shown for certain languages or if it is shown for all languages. More...
 
- Public Member Functions inherited from ilDatabaseUpdateSteps
 prepare (\ilDBInterface $db)
 Prepare the execution of the steps. More...
 

Private Member Functions

 abortIfNotPrepared ()
 Halts the execution of these update steps if no database was provided. More...
 

Private Attributes

ilDBInterface $database = null
 

Detailed Description

Author
Lukas Zehnder lukas.nosp@m.@sr..nosp@m.solut.nosp@m.ions

Definition at line 23 of file class.ilADNDatabaseObjective.php.

Member Function Documentation

◆ abortIfNotPrepared()

ilADNDatabaseObjective::abortIfNotPrepared ( )
private

Halts the execution of these update steps if no database was provided.

Exceptions
LogicExceptionif the database update steps were not yet prepared.

Definition at line 90 of file class.ilADNDatabaseObjective.php.

Referenced by step_1().

90  : void
91  {
92  if (null === $this->database) {
93  throw new LogicException(self::class . '::prepare() must be called before db-update-steps execution.');
94  }
95  }
+ Here is the caller graph for this function:

◆ prepare()

ilADNDatabaseObjective::prepare ( ilDBInterface  $db)

Definition at line 27 of file class.ilADNDatabaseObjective.php.

27  : void
28  {
29  $this->database = $db;
30  }

◆ step_1()

ilADNDatabaseObjective::step_1 ( )

Adds a new table column called 'has_language_limitation' which is used to define whether a notification is only shown for certain languages or if it is shown for all languages.

Also adds a new table column called 'limited_to_languages' which specifies which languages a notification with

the above limitation is shown for.

NOTE: the initial values will be set to 0 and "" respectively so that existing notifications will not be affected.

Definition at line 41 of file class.ilADNDatabaseObjective.php.

References abortIfNotPrepared().

41  : void
42  {
43  $this->abortIfNotPrepared();
44 
45  if (!$this->database->tableExists('il_adn_notifications') ||
46  $this->database->tableColumnExists('il_adn_notifications', 'has_language_limitation')
47  ) {
48  return;
49  }
50  $this->database->addTableColumn(
51  'il_adn_notifications',
52  'has_language_limitation',
53  [
54  'type' => 'integer',
55  'length' => 1,
56  'notnull' => true,
57  'default' => 0,
58  ]
59  );
60  $this->database->manipulate('
61  UPDATE il_adn_notifications SET has_language_limitation = 0;
62  ');
63 
64  if ($this->database->tableColumnExists('il_adn_notifications', 'limited_to_languages')
65  ) {
66  return;
67  }
68  $this->database->addTableColumn(
69  'il_adn_notifications',
70  'limited_to_languages',
71  [
72  'type' => 'text',
73  'length' => 256,
74  'notnull' => true,
75  'default' => '',
76  ]
77  );
78  $this->database->manipulate('
79  UPDATE il_adn_notifications SET limited_to_languages = "[]";
80  ');
81  }
abortIfNotPrepared()
Halts the execution of these update steps if no database was provided.
+ Here is the call graph for this function:

Field Documentation

◆ $database

ilDBInterface ilADNDatabaseObjective::$database = null
private

Definition at line 25 of file class.ilADNDatabaseObjective.php.


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