ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
LanguageAdaptor.php
Go to the documentation of this file.
1<?php
2
10
11 private $langattr = 'preferredLanguage';
12
13
20 public function __construct($config, $reserved) {
21 parent::__construct($config, $reserved);
22 assert('is_array($config)');
23
24 if (array_key_exists('attributename', $config)) {
25 $this->langattr = $config['attributename'];
26 }
27 }
28
29
37 public function process(&$request) {
38 assert('is_array($request)');
39 assert('array_key_exists("Attributes", $request)');
40
41 $attributes =& $request['Attributes'];
42
43 $attrlang = NULL;
44 if (array_key_exists($this->langattr, $attributes))
45 $attrlang = $attributes[$this->langattr][0];
46
48
49
50 if (isset($attrlang))
51 SimpleSAML\Logger::debug('LanguageAdaptor: Language in attribute was set [' . $attrlang . ']');
52 if (isset($lang))
53 SimpleSAML\Logger::debug('LanguageAdaptor: Language in session was set [' . $lang . ']');
54
55
56 if (isset($attrlang) && !isset($lang)) {
57 // Language set in attribute but not in cookie - update cookie
59 } elseif (!isset($attrlang) && isset($lang)) {
60 // Language set in cookie, but not in attribute. Update attribute
61 $request['Attributes'][$this->langattr] = array($lang);
62 }
63
64 }
65
66}
An exception for terminatinating execution or to throw for unit testing.
static getLanguageCookie()
Retrieve the user-selected language from a cookie.
Definition: Language.php:377
static setLanguageCookie($language)
This method will attempt to set the user-selected language in a cookie.
Definition: Language.php:400
static debug($string)
Definition: Logger.php:213
process(&$request)
Apply filter to add or replace attributes.
__construct($config, $reserved)
Initialize this filter.
$lang
Definition: consent.php:3
$attributes