1 | <?php |
||
9 | class FieldURIManager |
||
10 | { |
||
11 | protected static $unIndexedFieldURIs = []; |
||
12 | protected static $dictionaryFieldURIs = []; |
||
13 | |||
14 | /** |
||
15 | * @deprecated This will be made protected in 0.9 |
||
16 | */ |
||
17 | public static function setupFieldUris() |
||
18 | { |
||
19 | if (!empty(self::$dictionaryFieldURIs) && !empty(self::$dictionaryFieldURIs)) { |
||
20 | return; |
||
21 | } |
||
22 | |||
23 | self::$unIndexedFieldURIs = self::getFieldUrisFromClass(UnindexedFieldURIType::class); |
||
|
|||
24 | self::$dictionaryFieldURIs = self::getFieldUrisFromClass(DictionaryURIType::class); |
||
25 | } |
||
26 | |||
27 | 1 | public static function getDictionaryURIFields() |
|
28 | { |
||
29 | 1 | self::setupFieldUris(); |
|
30 | 1 | return self::$dictionaryFieldURIs; |
|
31 | } |
||
32 | |||
33 | /** |
||
34 | * @deprecated This will be made protected in 0.9 |
||
35 | * |
||
36 | * @param $className |
||
37 | * @return array |
||
38 | */ |
||
39 | public static function getFieldUrisFromClass($className) |
||
40 | { |
||
41 | //So, since we have to pass in URI's of everything we update, we need to fetch them |
||
42 | $reflection = new \ReflectionClass($className); |
||
43 | $constants = $reflection->getConstants(); |
||
44 | $constantsFound = array(); |
||
45 | |||
46 | //Loop through all URI's to list them in an array |
||
47 | foreach ($constants as $constant) { |
||
48 | $exploded = explode(":", strtolower($constant)); |
||
49 | if (count($exploded) == 1) { |
||
50 | $exploded = ['item', $exploded[0]]; |
||
51 | } |
||
52 | |||
53 | //It starts in order ['contacts', 'physicaladdress', 'city], we want it in |
||
54 | //['physicaladdress', 'contacts', 'city] |
||
55 | $temp = $exploded[0]; |
||
56 | $exploded[0] = $exploded[1]; |
||
57 | $exploded[1] = $temp; |
||
58 | |||
59 | $depth = count($exploded) - 1; |
||
60 | $current = &$constantsFound; |
||
61 | |||
62 | //Use the exploded array as a way to create a multidimensional array. For example, |
||
63 | //['contacts', 'physicaladdress', 'city'] becomes |
||
64 | //['contacts' => ['physicaladdress' => ['city' => 'contacts:PhysicalAddress:City']]] |
||
65 | foreach ($exploded as $count => $key) { |
||
66 | if ($count < $depth && !isset($current[$key])) { |
||
67 | $current[$key] = array(); |
||
68 | } |
||
69 | |||
70 | if ($count < $depth) { |
||
71 | $current = &$current[$key]; |
||
72 | continue; |
||
73 | } |
||
74 | |||
75 | $current[$key] = $constant; |
||
76 | } |
||
77 | } |
||
78 | |||
79 | return $constantsFound; |
||
80 | } |
||
81 | |||
82 | 6 | public static function getFieldUriByName($fieldName, $preference = 'item') |
|
102 | |||
103 | 1 | public static function getIndexedFieldUriByName($fieldName, $preference = 'item', $entryKey = false) |
|
104 | { |
||
105 | 1 | self::setupFieldUris(); |
|
129 | } |
||
130 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.