ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
SettingsDBRepository.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Portfolio\Settings;
22 
23 use ilDBInterface;
25 
27 {
28  public function __construct(
29  protected ilDBInterface $db,
30  protected InternalDataService $data
31  ) {
32  }
33 
34  public function create(Settings $settings): void
35  {
36  $this->db->insert('usr_portfolio', [
37  'id' => ['integer', $settings->getId()],
38  'ppic' => ['integer', $settings->getShowPersonalPicture()]
39  ]);
40  }
41 
42  public function update(Settings $settings): void
43  {
44  $this->db->update('usr_portfolio', [
45  'ppic' => ['integer', $settings->getShowPersonalPicture()]
46  ], [
47  'id' => ['integer', $settings->getId()],
48  ]);
49  }
50 
51  public function getById(int $id): ?Settings
52  {
53  $set = $this->db->queryF(
54  'SELECT * FROM usr_portfolio WHERE id = %s',
55  ['integer'],
56  [$id]
57  );
58  $rec = $this->db->fetchAssoc($set);
59  if ($rec) {
60  return $this->getSettingsFromRecord($rec);
61  }
62  return null;
63  }
64 
65  public function delete(int $id): void
66  {
67  $this->db->manipulateF(
68  'DELETE FROM usr_portfolio WHERE id = %s',
69  ['integer'],
70  [$id]
71  );
72  }
73 
74  protected function getSettingsFromRecord(array $rec): Settings
75  {
76  return $this->data->settings(
77  (int) $rec['id'],
78  (bool) $rec['ppic']
79  );
80  }
81 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(protected ilDBInterface $db, protected InternalDataService $data)