ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilADNDatabaseObjective.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
24 {
25  private ?ilDBInterface $database = null;
26 
27  public function prepare(ilDBInterface $db): void
28  {
29  $this->database = $db;
30  }
31 
32 
41  public function step_1(): 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  }
82 
83 
90  private function abortIfNotPrepared(): void
91  {
92  if (null === $this->database) {
93  throw new LogicException(self::class . '::prepare() must be called before db-update-steps execution.');
94  }
95  }
96 }
abortIfNotPrepared()
Halts the execution of these update steps if no database was provided.
step_1()
Adds a new table column called &#39;has_language_limitation&#39; which is used to define whether a notificati...