| @@ -50,24 +50,20 @@ | ||
| 50 | 50 | $pagination = new PaginationHelper(); |
| 51 | 51 | $settings['elementsPerPage'] = $pagination->getListLimit(); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $results['elements'] = acym_loadObjectList($query, '', $settings['offset'], $settings['elementsPerPage']); | |
| 55 | - $results['total'] = acym_loadObject($queryCount); | |
| 56 | - | |
| 57 | - return $results; | |
| 54 | + return [ | |
| 55 | + 'elements' => acym_loadObjectList($query, '', $settings['offset'], $settings['elementsPerPage']), | |
| 56 | + 'total' => acym_loadObject($queryCount), | |
| 57 | + ]; | |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function duplicate($mailboxIds) | |
| 60 | + public function duplicate(array $mailboxIds): void | |
| 61 | 61 | { |
| 62 | 62 | if (empty($mailboxIds)) { |
| 63 | 63 | return; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if (!is_array($mailboxIds)) { | |
| 67 | - $mailboxIds = [$mailboxIds]; | |
| 68 | - } | |
| 69 | - | |
| 70 | 66 | $duplicateErrors = []; |
| 71 | 67 | foreach ($mailboxIds as $mailboxId) { |
| 72 | 68 | $mailbox = $this->getOneById($mailboxId); |
| 73 | 69 | |
| @@ -74,12 +70,14 @@ | ||
| 74 | 70 | if (empty($mailbox)) { |
| 75 | 71 | continue; |
| 76 | 72 | } |
| 77 | 73 | |
| 78 | - $originalName = $mailbox->name; | |
| 74 | + $originalName = $mailbox->name ?? ''; | |
| 79 | 75 | unset($mailbox->id); |
| 80 | 76 | $mailbox->active = 0; |
| 81 | 77 | $mailbox->name .= '_copy'; |
| 78 | + $mailbox->conditions = json_encode($mailbox->conditions); | |
| 79 | + $mailbox->actions = json_encode($mailbox->actions); | |
| 82 | 80 | |
| 83 | 81 | if (empty($this->save($mailbox))) { |
| 84 | 82 | $duplicateErrors[] = acym_translationSprintf('ACYM_ERROR_DUPLICATING_MAILBOX_ACTION', $originalName); |
| 85 | 83 | } |
| @@ -89,17 +87,19 @@ | ||
| 89 | 87 | acym_enqueueMessage($duplicateErrors, 'error'); |
| 90 | 88 | } |
| 91 | 89 | } |
| 92 | 90 | |
| 93 | - public function getOneById($id) | |
| 91 | + public function getOneById(int $id): ?object | |
| 94 | 92 | { |
| 95 | 93 | $mailbox = acym_loadObject('SELECT * FROM #__acym_mailbox_action WHERE `id` = '.intval($id)); |
| 96 | 94 | |
| 97 | - if (!empty($mailbox)) { | |
| 98 | - $mailbox->conditions = json_decode($mailbox->conditions, true); | |
| 99 | - $mailbox->actions = json_decode($mailbox->actions, true); | |
| 95 | + if (empty($mailbox)) { | |
| 96 | + return null; | |
| 100 | 97 | } |
| 101 | 98 | |
| 99 | + $mailbox->conditions = json_decode($mailbox->conditions, true); | |
| 100 | + $mailbox->actions = json_decode($mailbox->actions, true); | |
| 101 | + | |
| 102 | 102 | return $mailbox; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | public function getAllActiveReadyWithActions(): array |
| @@ -112,9 +112,9 @@ | ||
| 112 | 112 | |
| 113 | 113 | return array_map([$this, 'decodeMailbox'], $mailboxes); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - public function decodeMailbox($mailbox) | |
| 116 | + private function decodeMailbox(object $mailbox): object | |
| 117 | 117 | { |
| 118 | 118 | $mailbox->conditions = json_decode($mailbox->conditions, true); |
| 119 | 119 | $mailbox->actions = json_decode($mailbox->actions, true); |
| 120 | 120 | |