| Conditions | 5 |
| Paths | 5 |
| Total Lines | 37 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 50 | public function buildForm(array $form, FormStateInterface $form_state) { |
||
|
|
|||
| 51 | $config = $this->config(Logger::CONFIG_NAME); |
||
| 52 | foreach ($config->getRawData() as $key => $default_value) { |
||
| 53 | if (Unicode::substr($key, 0, 1) === '_') { |
||
| 54 | continue; |
||
| 55 | } |
||
| 56 | $schema = $this->typed['mapping'][$key]; |
||
| 57 | list($title, $description) = explode(': ', $schema['label']); |
||
| 58 | $form[$key] = [ |
||
| 59 | '#default_value' => $default_value, |
||
| 60 | '#description' => $description, |
||
| 61 | '#title' => $title, |
||
| 62 | ]; |
||
| 63 | |||
| 64 | switch ($schema['type']) { |
||
| 65 | case 'integer': |
||
| 66 | $form[$key] += [ |
||
| 67 | '#max' => $schema['max'] ?? PHP_INT_MAX, |
||
|
1 ignored issue
–
show
|
|||
| 68 | '#min' => $schema['min'] ?? 0, |
||
|
1 ignored issue
–
show
|
|||
| 69 | '#type' => 'number', |
||
| 70 | ]; |
||
| 71 | break; |
||
| 72 | |||
| 73 | case 'boolean': |
||
|
1 ignored issue
–
show
|
|||
| 74 | $form[$key] += [ |
||
| 75 | '#type' => 'checkbox', |
||
| 76 | ]; |
||
| 77 | break; |
||
| 78 | |||
| 79 | default: |
||
|
1 ignored issue
–
show
|
|||
| 80 | break; |
||
| 81 | } |
||
| 82 | } |
||
| 83 | |||
| 84 | $form = parent::buildForm($form, $form_state); |
||
| 85 | return $form; |
||
| 86 | } |
||
| 87 | |||
| 122 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.