ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADNDatabaseObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 private ?ilDBInterface $database = null;
27
28 public function prepare(ilDBInterface $db): void
29 {
30 $this->database = $db;
31 }
32
33
42 public function step_1(): void
43 {
44 $this->abortIfNotPrepared();
45
46 if (!$this->database->tableExists('il_adn_notifications') ||
47 $this->database->tableColumnExists('il_adn_notifications', 'has_language_limitation')
48 ) {
49 return;
50 }
51 $this->database->addTableColumn(
52 'il_adn_notifications',
53 'has_language_limitation',
54 [
55 'type' => 'integer',
56 'length' => 1,
57 'notnull' => true,
58 'default' => 0,
59 ]
60 );
61 $this->database->manipulate('
62 UPDATE il_adn_notifications SET has_language_limitation = 0;
63 ');
64
65 if ($this->database->tableColumnExists('il_adn_notifications', 'limited_to_languages')
66 ) {
67 return;
68 }
69 $this->database->addTableColumn(
70 'il_adn_notifications',
71 'limited_to_languages',
72 [
73 'type' => 'text',
74 'length' => 256,
75 'notnull' => true,
76 'default' => '',
77 ]
78 );
79 $this->database->manipulate('
80 UPDATE il_adn_notifications SET limited_to_languages = "[]";
81 ');
82 }
83
84
91 private function abortIfNotPrepared(): void
92 {
93 if (null === $this->database) {
94 throw new LogicException(self::class . '::prepare() must be called before db-update-steps execution.');
95 }
96 }
97}
abortIfNotPrepared()
Halts the execution of these update steps if no database was provided.
step_1()
Adds a new table column called 'has_language_limitation' which is used to define whether a notificati...
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...