ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Settings.php
Go to the documentation of this file.
1 <?php
2 
4 
11 
12 class Settings
13 {
20  private static $chartRenderer;
21 
27  private static $libXmlLoaderOptions = null;
28 
38  private static $libXmlDisableEntityLoader = true;
39 
45  private static $cache;
46 
52  private static $httpClient;
53 
57  private static $requestFactory;
58 
66  public static function setLocale($locale)
67  {
68  return Calculation::getInstance()->setLocale($locale);
69  }
70 
77  public static function setChartRenderer($rendererClass): void
78  {
79  if (!is_a($rendererClass, IRenderer::class, true)) {
80  throw new Exception('Chart renderer must implement ' . IRenderer::class);
81  }
82 
83  self::$chartRenderer = $rendererClass;
84  }
85 
92  public static function getChartRenderer()
93  {
94  return self::$chartRenderer;
95  }
96 
102  public static function setLibXmlLoaderOptions($options): void
103  {
104  if ($options === null && defined('LIBXML_DTDLOAD')) {
105  $options = LIBXML_DTDLOAD | LIBXML_DTDATTR;
106  }
107  self::$libXmlLoaderOptions = $options;
108  }
109 
116  public static function getLibXmlLoaderOptions()
117  {
118  if (self::$libXmlLoaderOptions === null && defined('LIBXML_DTDLOAD')) {
119  self::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR);
120  } elseif (self::$libXmlLoaderOptions === null) {
121  self::$libXmlLoaderOptions = 0;
122  }
123 
124  return self::$libXmlLoaderOptions;
125  }
126 
137  public static function setLibXmlDisableEntityLoader($state): void
138  {
139  self::$libXmlDisableEntityLoader = (bool) $state;
140  }
141 
147  public static function getLibXmlDisableEntityLoader()
148  {
149  return self::$libXmlDisableEntityLoader;
150  }
151 
155  public static function setCache(CacheInterface $cache): void
156  {
157  self::$cache = $cache;
158  }
159 
165  public static function getCache()
166  {
167  if (!self::$cache) {
168  self::$cache = new Memory();
169  }
170 
171  return self::$cache;
172  }
173 
178  {
179  self::$httpClient = $httpClient;
180  self::$requestFactory = $requestFactory;
181  }
182 
186  public static function unsetHttpClient(): void
187  {
188  self::$httpClient = null;
189  self::$requestFactory = null;
190  }
191 
195  public static function getHttpClient(): ClientInterface
196  {
197  self::assertHttpClient();
198 
199  return self::$httpClient;
200  }
201 
205  public static function getRequestFactory(): RequestFactoryInterface
206  {
207  self::assertHttpClient();
208 
209  return self::$requestFactory;
210  }
211 
212  private static function assertHttpClient(): void
213  {
214  if (!self::$httpClient || !self::$requestFactory) {
215  throw new Exception('HTTP client must be configured via Settings::setHttpClient() to be able to use WEBSERVICE function.');
216  }
217  }
218 }
static getCache()
Gets the implementation of cache that should be used for cell collection.
Definition: Settings.php:165
static setLocale($locale)
Set the locale code to use for formula translations and any special formatting.
Definition: Settings.php:66
static setHttpClient(ClientInterface $httpClient, RequestFactoryInterface $requestFactory)
Set the HTTP client implementation to be used for network request.
Definition: Settings.php:177
static getChartRenderer()
Return the Chart Rendering Library that PhpSpreadsheet is currently configured to use...
Definition: Settings.php:92
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
static getLibXmlDisableEntityLoader()
Return the state of the entity loader (disabled/enabled) for libxml loader.
Definition: Settings.php:147
static setChartRenderer($rendererClass)
Identify to PhpSpreadsheet the external library to use for rendering charts.
Definition: Settings.php:77
static getHttpClient()
Get the HTTP client implementation to be used for network request.
Definition: Settings.php:195
static getRequestFactory()
Get the HTTP request factory.
Definition: Settings.php:205
static unsetHttpClient()
Unset the HTTP client configuration.
Definition: Settings.php:186
static getInstance(?Spreadsheet $spreadsheet=null)
Get an instance of this class.
static setCache(CacheInterface $cache)
Sets the implementation of cache that should be used for cell collection.
Definition: Settings.php:155
static getLibXmlLoaderOptions()
Get default options for libxml loader.
Definition: Settings.php:116
This is the default implementation for in-memory cell collection.
Definition: Memory.php:13
static setLibXmlLoaderOptions($options)
Set default options for libxml loader.
Definition: Settings.php:102
static setLibXmlDisableEntityLoader($state)
Enable/Disable the entity loader for libxml loader.
Definition: Settings.php:137