ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  case self::CONTEXT_AGRREMENT_BY_LANGUAGE:
40  $this->validateConfiguration(array('lng'));
41  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceAgreementByLanguageProvider.php';
42  return new ilTermsOfServiceAgreementByLanguageProvider($this->lng);
43 
44  case self::CONTEXT_ACCEPTANCE_HISTORY:
45  $this->validateConfiguration(array('db'));
46  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceAcceptanceHistoryProvider.php';
48 
49  default:
50  throw new InvalidArgumentException('Provider not supported');
51  }
52  }
53 
59  protected function validateConfiguration(array $mandatory_members)
60  {
61  foreach ($mandatory_members as $member) {
62  if (null == $this->{$member}) {
63  $exception = $this->getExceptionByMember($member);
64  throw $exception;
65  }
66  }
67  }
68 
74  protected function getExceptionByMember($member)
75  {
76  switch ($member) {
77  case 'lng':
78  require_once 'Services/TermsOfService/exceptions/class.ilTermsOfServiceMissingLanguageAdapterException.php';
79  return new ilTermsOfServiceMissingLanguageAdapterException('Incomplete factory configuration. Please inject a language adapter.');
80 
81  case 'db':
82  require_once 'Services/TermsOfService/exceptions/class.ilTermsOfServiceMissingDatabaseAdapterException.php';
83  return new ilTermsOfServiceMissingDatabaseAdapterException('Incomplete factory configuration. Please inject a database adapter.');
84 
85  default:
86  throw new InvalidArgumentException("Exveption for member {$member} not supported");
87  }
88  }
89 
93  public function setLanguageAdapter($lng)
94  {
95  $this->lng = $lng;
96  }
97 
101  public function getLanguageAdapter()
102  {
103  return $this->lng;
104  }
105 
109  public function setDatabaseAdapter($db)
110  {
111  $this->db = $db;
112  }
113 
117  public function getDatabaseAdapter()
118  {
119  return $this->db;
120  }
121 }
Create styles array
The data for the language used.