ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AttributeCopy.php
Go to the documentation of this file.
1<?php
2
19
23 private $map = array();
24
25
32 public function __construct($config, $reserved) {
33 parent::__construct($config, $reserved);
34
35 assert(is_array($config));
36
37 foreach($config as $source => $destination) {
38
39 if(!is_string($source)) {
40 throw new Exception('Invalid source attribute name: ' . var_export($source, TRUE));
41 }
42
43 if(!is_string($destination) && !is_array($destination)) {
44 throw new Exception('Invalid destination attribute name: ' . var_export($destination, TRUE));
45 }
46
47 $this->map[$source] = $destination;
48 }
49 }
50
51
57 public function process(&$request) {
58 assert(is_array($request));
59 assert(array_key_exists('Attributes', $request));
60
61 $attributes =& $request['Attributes'];
62
63 foreach($attributes as $name => $values) {
64 if (array_key_exists($name,$this->map)){
65 if (!is_array($this->map[$name])) {
66 $attributes[$this->map[$name]] = $values;
67 } else {
68 foreach ($this->map[$name] as $to_map) {
69 $attributes[$to_map] = $values;
70 }
71 }
72 }
73 }
74
75 }
76}
foreach($paths as $path) $request
Definition: asyncclient.php:32
$source
Definition: linkback.php:22
An exception for terminatinating execution or to throw for unit testing.
$map
Assosiative array with the mappings of attribute names.
__construct($config, $reserved)
Initialize this filter, parse configuration.
process(&$request)
Apply filter to rename attributes.
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85
$config
Definition: bootstrap.php:15
$destination
$values