ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SettingsDBRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
27{
28 public function __construct(
29 protected ilDBInterface $db,
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}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Repository internal data service.
__construct(protected ilDBInterface $db, protected InternalDataService $data)
Interface ilDBInterface.