1 | <?php |
||
10 | class ReorderFields |
||
11 | { |
||
12 | /** |
||
13 | * Given a simple list of user-supplied field keys or field labels, |
||
14 | * return a reordered version of the field labels matching the |
||
15 | * user selection. |
||
16 | * |
||
17 | * @param string|array $fields The user-selected fields |
||
18 | * @param array $fieldLabels An associative array mapping the field |
||
19 | * key to the field label |
||
20 | * @param array $data The data that will be rendered. |
||
21 | * |
||
22 | 7 | * @return array |
|
23 | */ |
||
24 | 7 | public function reorder($fields, $fieldLabels, $data) |
|
36 | |||
37 | 2 | protected function reorderFieldLabels($fields, $fieldLabels, $data) |
|
50 | |||
51 | 7 | protected function getSelectedFieldKeys($fields, $fieldLabels) |
|
63 | 7 | ||
64 | protected function matchFieldInLabelMap($field, $fieldLabels) |
||
77 | |||
78 | /** |
||
79 | * Convert the provided string into a regex suitable for use in |
||
80 | * preg_match. |
||
81 | * |
||
82 | * Matching occurs in the same way as the Symfony Finder component: |
||
83 | * http://symfony.com/doc/current/components/finder.html#file-name |
||
84 | */ |
||
85 | protected function convertToRegex($str) |
||
89 | |||
90 | /** |
||
91 | * Checks whether the string is a regex. This function is copied from |
||
92 | * MultiplePcreFilterIterator in the Symfony Finder component. |
||
93 | * |
||
94 | * @param string $str |
||
95 | * |
||
96 | * @return bool Whether the given string is a regex |
||
97 | */ |
||
98 | protected function isRegex($str) |
||
117 | } |
||
118 |