Skip to content

Commit

Permalink
persist
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed May 16, 2024
1 parent ef5ae22 commit 6e889b4
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions application/forms/RotationConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use DateTime;
use Generator;
use Icinga\Exception\Http\HttpNotFoundException;
use Icinga\Exception\NotImplementedError;
use Icinga\Module\Notifications\Common\Database;
use Icinga\Module\Notifications\Model\Contact;
use Icinga\Module\Notifications\Model\Contactgroup;
Expand Down Expand Up @@ -365,7 +364,26 @@ public function editRotation(int $rotationId): void
*/
public function removeRotation(int $id): void
{
throw new NotImplementedError('Not implemented');
$transactionStarted = false;
if (! $this->db->inTransaction()) {
$transactionStarted = $this->db->beginTransaction();
}

$timeperiodId = $this->db->fetchScalar(
(new Select())
->from('timeperiod')
->columns('id')
->where(['owned_by_rotation_id = ?' => $id])
);

$this->db->delete('timeperiod_entry', ['timeperiod_id = ?' => $timeperiodId]);
$this->db->delete('timeperiod', ['id = ?' => $timeperiodId]);
$this->db->delete('rotation_member', ['rotation_id = ?' => $id]);
$this->db->delete('rotation', ['id = ?' => $id]);

if ($transactionStarted) {
$this->db->commitTransaction();
}
}

protected function assembleModeSelection(): string
Expand Down

0 comments on commit 6e889b4

Please sign in to comment.