| Total Complexity | 5 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | class Services_ChangeStateOrDelete_Handler |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * Register pre delete. |
||
| 19 | * |
||
| 20 | * @param App\EventHandler $eventHandler |
||
| 21 | * |
||
| 22 | * @return array |
||
| 23 | */ |
||
| 24 | public function preDelete(App\EventHandler $eventHandler) |
||
| 25 | { |
||
| 26 | $recordModel = $eventHandler->getRecordModel(); |
||
| 27 | $result = ['result' => true]; |
||
| 28 | if (\App\Record::isRelated($recordModel, false, true)) { |
||
| 29 | $result = [ |
||
| 30 | 'result' => false, |
||
| 31 | 'type' => 'confirm', |
||
| 32 | 'message' => App\Language::translate('LBL_CONFIRM_DELETE_WHEN_HAS_RELATION', $recordModel->getModuleName()), |
||
| 33 | 'hash' => hash('sha256', implode('|', $recordModel->getData())) |
||
| 34 | ]; |
||
| 35 | } |
||
| 36 | return $result; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Register pre state change. |
||
| 41 | * |
||
| 42 | * @param App\EventHandler $eventHandler |
||
| 43 | * |
||
| 44 | * @return array |
||
| 45 | */ |
||
| 46 | public function preStateChange(App\EventHandler $eventHandler) |
||
| 59 | } |
||
| 60 | } |
||
| 61 |