ILIAS  release_8 Revision v8.24
class.ilLanguageDetectorFactory.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
28{
29 private const DEFAULT_DETECTOR = 1;
30 private const HTTP_REQUEST_DETECTOR = 2;
31
33 protected array $request_information = array();
35
36 public function __construct()
37 {
38 global $DIC;
39
40 $this->client_ini = $DIC->clientIni();
41 $this->request_information = $_SERVER;
42 $this->settings = $DIC->settings();
43 }
44
48 public function getValidInstances(): array
49 {
50 $detectors = array(
51 $this->createDetectorByType(self::DEFAULT_DETECTOR)
52 );
53
54 if ($this->settings->get("lang_detection") &&
56 array_key_exists('HTTP_ACCEPT_LANGUAGE', $this->request_information)
57 ) {
58 $detectors[] = $this->createDetectorByType(self::HTTP_REQUEST_DETECTOR);
59 }
60
61 return $detectors;
62 }
63
67 public function createDetectorByType(int $type)
68 {
69 switch ($type) {
71 require_once "Services/Language/classes/class.ilHttpRequestsLanguageDetector.php";
72 return new ilHttpRequestsLanguageDetector($this->request_information["HTTP_ACCEPT_LANGUAGE"]);
73
75 require_once "Services/Language/classes/class.ilDefaultLanguageDetector.php";
76 return new ilDefaultLanguageDetector($this->client_ini);
77 }
78
79 require_once "Services/Language/exceptions/class.ilLanguageException.php";
80 throw new ilLanguageException(__METHOD__ . sprintf("Cannot create language detector instance for type %s!", $type));
81 }
82}
static usesHTTP()
Uses HTTP aka browser.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$type
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10