ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLanguageDetectorFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 private const DEFAULT_DETECTOR = 1;
29 private const HTTP_REQUEST_DETECTOR = 2;
30
32 protected array $request_information = array();
34
35 public function __construct()
36 {
37 global $DIC;
38
39 $this->client_ini = $DIC->clientIni();
40 $this->request_information = $_SERVER;
41 $this->settings = $DIC->settings();
42 }
43
47 public function getValidInstances(): array
48 {
49 $detectors = array(
50 $this->createDetectorByType(self::DEFAULT_DETECTOR)
51 );
52
53 if ($this->settings->get("lang_detection") &&
55 array_key_exists('HTTP_ACCEPT_LANGUAGE', $this->request_information)
56 ) {
57 $detectors[] = $this->createDetectorByType(self::HTTP_REQUEST_DETECTOR);
58 }
59
60 return $detectors;
61 }
62
66 public function createDetectorByType(int $type)
67 {
68 switch ($type) {
70 return new ilHttpRequestsLanguageDetector($this->request_information["HTTP_ACCEPT_LANGUAGE"]);
71
73 return new ilDefaultLanguageDetector($this->client_ini);
74 }
75
76 throw new ilLanguageException(__METHOD__ . sprintf("Cannot create language detector instance for type %s!", $type));
77 }
78}
static usesHTTP()
Uses HTTP aka browser.
Class ilDefaultLanguageDetector.
Class ilHttpRequestsLanguageDetector.
INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other servic...
Class ilLanguageDetectorFactory.
Class for language related exception handling in ILIAS.
ILIAS Setting Class.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
global $DIC
Definition: shib_login.php:26