ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilPluginStateDBOverIlDBInterface Class Reference

Implementation of ilPluginStateDB over ilDBInterface. More...

+ Inheritance diagram for ilPluginStateDBOverIlDBInterface:
+ Collaboration diagram for ilPluginStateDBOverIlDBInterface:

Public Member Functions

 __construct (Data\Factory $data_factory, \ilDBInterface $db)
 
 isPluginActivated (string $id)
 
 setActivation (string $id, bool $activated)
 
 getCurrentPluginVersion (string $id)
 
 getCurrentPluginDBVersion (string $id)
 
 setCurrentPluginVersion (string $id, Version $version, int $db_version)
 
 remove (string $id)
 

Protected Member Functions

 getData ()
 

Protected Attributes

const TABLE_NAME = "il_plugin"
 
Data Factory $data_factory
 
ilDBInterface $db
 
bool $has_data = false
 
array $data = null
 

Detailed Description

Implementation of ilPluginStateDB over ilDBInterface.

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

Constructor & Destructor Documentation

◆ __construct()

ilPluginStateDBOverIlDBInterface::__construct ( Data\Factory  $data_factory,
\ilDBInterface  $db 
)

Definition at line 38 of file class.ilPluginStateDBOverIlDBInterface.php.

References $data_factory, and $db.

39  {
40  $this->data_factory = $data_factory;
41  $this->db = $db;
42  }

Member Function Documentation

◆ getCurrentPluginDBVersion()

ilPluginStateDBOverIlDBInterface::getCurrentPluginDBVersion ( string  $id)

Implements ilPluginStateDB.

Definition at line 94 of file class.ilPluginStateDBOverIlDBInterface.php.

References $id, and getData().

94  : ?int
95  {
96  $this->getData();
97  return $this->data[$id][2] ?? null;
98  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
+ Here is the call graph for this function:

◆ getCurrentPluginVersion()

ilPluginStateDBOverIlDBInterface::getCurrentPluginVersion ( string  $id)

Implements ilPluginStateDB.

Definition at line 88 of file class.ilPluginStateDBOverIlDBInterface.php.

References $id, and getData().

88  : ?Version
89  {
90  $this->getData();
91  return $this->data[$id][1] ?? null;
92  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
A version number that consists of three numbers (major, minor, patch).
Definition: Version.php:26
+ Here is the call graph for this function:

◆ getData()

ilPluginStateDBOverIlDBInterface::getData ( )
protected

Definition at line 44 of file class.ilPluginStateDBOverIlDBInterface.php.

References $data, $res, and ILIAS\Repository\int().

Referenced by getCurrentPluginDBVersion(), getCurrentPluginVersion(), isPluginActivated(), setActivation(), and setCurrentPluginVersion().

44  : void
45  {
46  if ($this->has_data) {
47  return;
48  }
49 
50  $res = $this->db->query("SELECT * FROM " . self::TABLE_NAME);
51  $this->data = [];
52  foreach ($this->db->fetchAll($res) as $data) {
53  $this->data[$data["plugin_id"]] = [
54  (bool) $data["active"],
55  $data["last_update_version"] ? $this->data_factory->version($data["last_update_version"]) : null,
56  $data["db_version"] ? (int) $data["db_version"] : null
57  ];
58  }
59  $this->has_data = true;
60  }
$res
Definition: ltiservices.php:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isPluginActivated()

ilPluginStateDBOverIlDBInterface::isPluginActivated ( string  $id)

Implements ilPluginStateDB.

Definition at line 62 of file class.ilPluginStateDBOverIlDBInterface.php.

References $id, and getData().

62  : bool
63  {
64  $this->getData();
65  return $this->data[$id][0] ?? false;
66  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
+ Here is the call graph for this function:

◆ remove()

ilPluginStateDBOverIlDBInterface::remove ( string  $id)

Implements ilPluginStateDB.

Definition at line 128 of file class.ilPluginStateDBOverIlDBInterface.php.

References $id.

128  : void
129  {
130  $this->db->manipulate(
131  "DELETE FROM " . self::TABLE_NAME . " WHERE plugin_id = " . $this->db->quote($id, "text")
132  );
133  $this->has_data = false;
134  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24

◆ setActivation()

ilPluginStateDBOverIlDBInterface::setActivation ( string  $id,
bool  $activated 
)

Implements ilPluginStateDB.

Definition at line 68 of file class.ilPluginStateDBOverIlDBInterface.php.

References getData().

68  : void
69  {
70  $this->getData();
71  if (!isset($this->data[$id])) {
72  throw new \InvalidArgumentException(
73  "Unknown plugin '$id'"
74  );
75  }
76  $this->db->update(
77  self::TABLE_NAME,
78  [
79  "active" => ["integer", $activated ? 1 : 0]
80  ],
81  [
82  "plugin_id" => ["text", $id]
83  ]
84  );
85  $this->has_data = false;
86  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
+ Here is the call graph for this function:

◆ setCurrentPluginVersion()

ilPluginStateDBOverIlDBInterface::setCurrentPluginVersion ( string  $id,
Version  $version,
int  $db_version 
)

Implements ilPluginStateDB.

Definition at line 100 of file class.ilPluginStateDBOverIlDBInterface.php.

References getData().

100  : void
101  {
102  $this->getData();
103  if (isset($this->data[$id])) {
104  $this->db->update(
105  self::TABLE_NAME,
106  [
107  "last_update_version" => ["text", (string) $version],
108  "db_version" => ["integer", $db_version]
109  ],
110  [
111  "plugin_id" => ["text", $id]
112  ]
113  );
114  } else {
115  $this->db->insert(
116  self::TABLE_NAME,
117  [
118  "plugin_id" => ["text", $id],
119  "active" => ["integer", 0],
120  "last_update_version" => ["text", (string) $version],
121  "db_version" => ["integer", $db_version]
122  ]
123  );
124  }
125  $this->has_data = false;
126  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
+ Here is the call graph for this function:

Field Documentation

◆ $data

array ilPluginStateDBOverIlDBInterface::$data = null
protected

Definition at line 36 of file class.ilPluginStateDBOverIlDBInterface.php.

Referenced by getData().

◆ $data_factory

Data Factory ilPluginStateDBOverIlDBInterface::$data_factory
protected

Definition at line 32 of file class.ilPluginStateDBOverIlDBInterface.php.

Referenced by __construct().

◆ $db

ilDBInterface ilPluginStateDBOverIlDBInterface::$db
protected

Definition at line 33 of file class.ilPluginStateDBOverIlDBInterface.php.

Referenced by __construct().

◆ $has_data

bool ilPluginStateDBOverIlDBInterface::$has_data = false
protected

Definition at line 35 of file class.ilPluginStateDBOverIlDBInterface.php.

◆ TABLE_NAME

const ilPluginStateDBOverIlDBInterface::TABLE_NAME = "il_plugin"
protected

Definition at line 30 of file class.ilPluginStateDBOverIlDBInterface.php.


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