| Total Complexity | 4 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class Form |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @param string $id |
||
| 14 | * @return void |
||
| 15 | */ |
||
| 16 | public function renderFields( $id ) |
||
| 17 | { |
||
| 18 | $fields = $this->getSettingFields( $this->normalizeSettingPath( $id )); |
||
| 19 | $rows = ''; |
||
| 20 | foreach( $fields as $name => $field ) { |
||
| 21 | $field = wp_parse_args( $field, ['name' => $name] ); |
||
| 22 | $rows.= (new Field( $field ))->build(); |
||
| 23 | } |
||
| 24 | glsr( Template::class )->render( 'pages/settings/'.$id, [ |
||
| 25 | 'context' => [ |
||
| 26 | 'rows' => $rows, |
||
| 27 | ], |
||
| 28 | ]); |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @return array |
||
| 33 | */ |
||
| 34 | protected function getSettingFields( $path ) |
||
| 35 | { |
||
| 36 | $settings = glsr( DefaultsManager::class )->settings(); |
||
| 37 | return array_filter( $settings, function( $key ) use( $path ) { |
||
| 38 | return glsr( Helper::class )->startsWith( $path, $key ); |
||
| 39 | }, ARRAY_FILTER_USE_KEY ); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @return string |
||
| 44 | */ |
||
| 45 | protected function normalizeSettingPath( $path ) |
||
| 48 | } |
||
| 49 | } |
||
| 50 |