ILIAS  release_8 Revision v8.24
class.ilTermsOfServiceTableDataProviderFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 public const CONTEXT_ACCEPTANCE_HISTORY = 'acceptance_history';
28 public const CONTEXT_DOCUMENTS = 'documents';
29
30 protected ?ilDBInterface $db = null;
31
39 {
40 switch ($context) {
42 $this->validateConfiguration(['db']);
44
47
48 default:
49 throw new InvalidArgumentException('Provider not supported');
50 }
51 }
52
57 protected function validateConfiguration(array $mandatoryMemberVariables): void
58 {
59 foreach ($mandatoryMemberVariables as $member) {
60 if (null === $this->{$member}) {
61 $exception = $this->getExceptionByMember($member);
62 throw $exception;
63 }
64 }
65 }
66
72 protected function getExceptionByMember(string $member): ilTermsOfServiceException
73 {
74 switch ($member) {
75 case 'db':
77 'Incomplete factory configuration. Please inject a database adapter.'
78 );
79
80 default:
81 throw new InvalidArgumentException("Exception for member $member not supported");
82 }
83 }
84
85 public function setDatabaseAdapter(?ilDBInterface $db): void
86 {
87 $this->db = $db;
88 }
89
91 {
92 return $this->db;
93 }
94}
Class ilTermsOfServiceMissingDatabaseAdapterException.
Interface ilDBInterface.
Interface ilTermsOfServiceTableDataProvider.
$context
Definition: webdav.php:29