-
Notifications
You must be signed in to change notification settings - Fork 7
/
parameter_property_mapper.class.php
55 lines (42 loc) · 1.37 KB
/
parameter_property_mapper.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
class ParameterPropertyMapper{
private $_config;
function __construct($config){
$this->_config = $config;
}
function paramNameToPropertyNames($name){
#remove min-/max-
$nameArray = $this->splitPrefixAndName($name);
$name = $nameArray['name'];
#split on dot
$splitNames = explode('.', $name);
return $splitNames;
}
function mapParamNameToProperties($name){
$splitNames = $this->paramNameToPropertyNames($name);
$list = array();
foreach($splitNames as $sn){
$uri = $this->_config->getUriForVocabPropertyLabel($sn);
$list[$sn] = $uri;
}
return $list;
}
function prefixFromParamName($name){
$a = $this->splitPrefixAndName($name);
return $a['prefix'];
}
private function splitPrefixAndName($name){
$prefixes = array('min', 'max', 'minEx', 'maxEx', 'name', 'exists', 'lang', 'true', 'false');
foreach($prefixes as $prefix){
if(strpos($name, $prefix.'-')===0){
$name = substr($name, strlen($prefix.'-'));
return array(
'name' => $name,
'prefix' => $prefix,
);
}
}
return array('name' => $name, 'prefix' => false);
}
}
?>