ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
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\MediaPool\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('mep_data', [
37  'id' => ['integer', $settings->getId()],
38  'default_width' => ['integer', $settings->getDefaultWidth()],
39  'default_height' => ['integer', $settings->getDefaultHeight()],
40  'for_translation' => ['integer', (int) $settings->getForTranslation()],
41  ]);
42  }
43 
44  public function update(Settings $settings): void
45  {
46  $this->db->update('mep_data', [
47  'default_width' => ['integer', $settings->getDefaultWidth()],
48  'default_height' => ['integer', $settings->getDefaultHeight()],
49  'for_translation' => ['integer', (int) $settings->getForTranslation()],
50  ], [
51  'id' => ['integer', $settings->getId()],
52  ]);
53  }
54 
55  public function getById(int $id): ?Settings
56  {
57  $set = $this->db->queryF(
58  'SELECT * FROM mep_data WHERE id = %s',
59  ['integer'],
60  [$id]
61  );
62 
63  $rec = $this->db->fetchAssoc($set);
64  if ($rec) {
65  return $this->getSettingsFromRecord($rec);
66  }
67 
68  return null;
69  }
70 
71  public function delete(int $id): void
72  {
73  $this->db->manipulateF(
74  'DELETE FROM mep_data WHERE id = %s',
75  ['integer'],
76  [$id]
77  );
78  }
79 
80  protected function getSettingsFromRecord(array $rec): Settings
81  {
82  return $this->data->settings(
83  (int) $rec['id'],
84  (int) $rec['default_width'],
85  (int) $rec['default_height'],
86  (bool) $rec['for_translation']
87  );
88  }
89 }
__construct(protected ilDBInterface $db, protected InternalDataService $data)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23