ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilTermsOfServiceTableDataProviderFactory.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
10 const CONTEXT_ACCEPTANCE_HISTORY = 'acceptance_history';
11 const CONTEXT_DOCUMENTS = 'documents';
12
14 protected $db;
15
23 {
24 switch ($context) {
26 $this->validateConfiguration(['db']);
28
31
32 default:
33 throw new InvalidArgumentException('Provider not supported');
34 }
35 }
36
41 protected function validateConfiguration(array $mandatoryMemberVariables) : void
42 {
43 foreach ($mandatoryMemberVariables as $member) {
44 if (null === $this->{$member}) {
45 $exception = $this->getExceptionByMember($member);
46 throw $exception;
47 }
48 }
49 }
50
56 protected function getExceptionByMember(string $member)
57 {
58 switch ($member) {
59 case 'db':
61 'Incomplete factory configuration. Please inject a database adapter.'
62 );
63
64 default:
65 throw new InvalidArgumentException("Exception for member {$member} not supported");
66 }
67 }
68
73 {
74 $this->db = $db;
75 }
76
80 public function getDatabaseAdapter() : ?ilDBInterface
81 {
82 return $this->db;
83 }
84}
An exception for terminatinating execution or to throw for unit testing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilTermsOfServiceTableDataProvider.
$context
Definition: webdav.php:26