| Conditions | 6 |
| Paths | 9 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | 1 | public function handle(FormInterface $form) |
|
| 20 | { |
||
| 21 | 1 | $data = $form->getData(); |
|
| 22 | 1 | $batchItems = []; |
|
| 23 | $cleanData = [ |
||
| 24 | 1 | 'ids' => [], |
|
| 25 | 1 | 'batch_action' => $data['batch_action'], |
|
| 26 | 1 | 'labels' => $this->getLabels($data['entities']) |
|
| 27 | 1 | ]; |
|
| 28 | |||
| 29 | // find batch items checkbox values |
||
| 30 | 1 | foreach ($data as $name => $batchItem) { |
|
| 31 | 1 | if (substr($name, 0, 6) == 'batch_') { |
|
| 32 | 1 | $batchItems[$name] = $batchItem; |
|
| 33 | 1 | } |
|
| 34 | 1 | } |
|
| 35 | // check if they exists in entities displayed and if checkbox is checked |
||
| 36 | 1 | foreach ($batchItems as $name => $batchItem) { |
|
| 37 | 1 | $batchId = (int) str_replace('batch_', '', $name); |
|
| 38 | |||
| 39 | 1 | if (array_key_exists($batchId, $cleanData['labels']) && $batchItem === true) { |
|
| 40 | 1 | $cleanData['ids'][] = $batchId; |
|
| 41 | 1 | } |
|
| 42 | 1 | } |
|
| 43 | 1 | return $cleanData; |
|
| 44 | } |
||
| 45 | |||
| 60 |