| Total Complexity | 2 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | trait ModalTrait |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * Show a modal dialog. |
||
| 19 | * |
||
| 20 | * @param string $sTitle The title of the dialog |
||
| 21 | * @param string $sContent The content of the dialog |
||
| 22 | * @param array $aButtons The buttons of the dialog |
||
| 23 | * @param array $aOptions The options of the dialog |
||
| 24 | * |
||
| 25 | * Each button is an array with the following entries: |
||
| 26 | * - title: the text to be printed in the button |
||
| 27 | * - class: the CSS class of the button |
||
| 28 | * - click: the javascript function to be called when the button is clicked |
||
| 29 | * If the click value is set to "close", then the button closes the dialog. |
||
| 30 | * |
||
| 31 | * The content of the $aOptions depends on the javascript library in use. |
||
| 32 | * Check their specific documentation for more information. |
||
| 33 | * |
||
| 34 | * @return array |
||
| 35 | */ |
||
| 36 | public function show(string $sTitle, string $sContent, array $aButtons, array $aOptions = []): array |
||
| 37 | { |
||
| 38 | return [ |
||
| 39 | 'dialog' => [ |
||
| 40 | 'title' => $sTitle, |
||
| 41 | 'content' => $sContent, |
||
| 42 | 'buttons' => $aButtons, |
||
| 43 | 'options' => $aOptions, |
||
| 44 | ], |
||
| 45 | ]; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Hide the modal dialog. |
||
| 50 | * |
||
| 51 | * @return array |
||
| 52 | */ |
||
| 53 | public function hide(): array |
||
| 56 | } |
||
| 57 | } |
||
| 58 |