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