ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 27 of file class.ilPluginStateDBOverIlDBInterface.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

References $data_factory, and $db.

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

Member Function Documentation

◆ getCurrentPluginDBVersion()

ilPluginStateDBOverIlDBInterface::getCurrentPluginDBVersion ( string  $id)

Implements ilPluginStateDB.

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

References $id, and getData().

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

◆ getCurrentPluginVersion()

ilPluginStateDBOverIlDBInterface::getCurrentPluginVersion ( string  $id)

Implements ilPluginStateDB.

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

References $id, and getData().

87  : ?Version
88  {
89  $this->getData();
90  return $this->data[$id][1] ?? null;
91  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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 43 of file class.ilPluginStateDBOverIlDBInterface.php.

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

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

43  : void
44  {
45  if ($this->has_data) {
46  return;
47  }
48 
49  $res = $this->db->query("SELECT * FROM " . self::TABLE_NAME);
50  $this->data = [];
51  foreach ($this->db->fetchAll($res) as $data) {
52  $this->data[$data["plugin_id"]] = [
53  (bool) $data["active"],
54  $data["last_update_version"] ? $this->data_factory->version($data["last_update_version"]) : null,
55  $data["db_version"] ? (int) $data["db_version"] : null
56  ];
57  }
58  $this->has_data = true;
59  }
$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 61 of file class.ilPluginStateDBOverIlDBInterface.php.

References $id, and getData().

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

◆ remove()

ilPluginStateDBOverIlDBInterface::remove ( string  $id)

Implements ilPluginStateDB.

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

References $id.

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

◆ setActivation()

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

Implements ilPluginStateDB.

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

References getData().

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

◆ setCurrentPluginVersion()

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

Implements ilPluginStateDB.

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

References getData().

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

Field Documentation

◆ $data

array ilPluginStateDBOverIlDBInterface::$data = null
protected

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

Referenced by getData().

◆ $data_factory

Data Factory ilPluginStateDBOverIlDBInterface::$data_factory
protected

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

Referenced by __construct().

◆ $db

ilDBInterface ilPluginStateDBOverIlDBInterface::$db
protected

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

Referenced by __construct().

◆ $has_data

bool ilPluginStateDBOverIlDBInterface::$has_data = false
protected

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

◆ TABLE_NAME

const ilPluginStateDBOverIlDBInterface::TABLE_NAME = "il_plugin"
protected

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


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