ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilTermsOfServiceTableDataProviderFactory.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
13 protected $lng;
14
18 protected $db;
19
23 const CONTEXT_AGRREMENT_BY_LANGUAGE = 'agreements_by_language';
24
28 const CONTEXT_ACCEPTANCE_HISTORY = 'acceptance_history';
29
36 public function getByContext($context)
37 {
38 switch($context)
39 {
41 $this->validateConfiguration(array('lng'));
42 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceAgreementByLanguageProvider.php';
44
46 $this->validateConfiguration(array('db'));
47 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceAcceptanceHistoryProvider.php';
49
50 default:
51 throw new InvalidArgumentException('Provider not supported');
52 }
53 }
54
60 protected function validateConfiguration(array $mandatory_members)
61 {
62 foreach($mandatory_members as $member)
63 {
64 if(null == $this->{$member})
65 {
66 $exception = $this->getExceptionByMember($member);
67 throw $exception;
68 }
69 }
70 }
71
77 protected function getExceptionByMember($member)
78 {
79 switch($member)
80 {
81 case 'lng':
82 require_once 'Services/TermsOfService/exceptions/class.ilTermsOfServiceMissingLanguageAdapterException.php';
83 return new ilTermsOfServiceMissingLanguageAdapterException('Incomplete factory configuration. Please inject a language adapter.');
84
85 case 'db':
86 require_once 'Services/TermsOfService/exceptions/class.ilTermsOfServiceMissingDatabaseAdapterException.php';
87 return new ilTermsOfServiceMissingDatabaseAdapterException('Incomplete factory configuration. Please inject a database adapter.');
88
89 default:
90 throw new InvalidArgumentException("Exveption for member {$member} not supported");
91 }
92 }
93
97 public function setLanguageAdapter($lng)
98 {
99 $this->lng = $lng;
100 }
101
105 public function getLanguageAdapter()
106 {
107 return $this->lng;
108 }
109
113 public function setDatabaseAdapter($db)
114 {
115 $this->db = $db;
116 }
117
121 public function getDatabaseAdapter()
122 {
123 return $this->db;
124 }
125}