Completed
Push — master ( 35046b...d215ab )
by Mikołaj
03:13
created

ExamDelete::postDeleteAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace Egzaminer\Exam;
4
5
use Egzaminer\Admin\Dashboard as Controller;
6
7
class ExamDelete extends Controller
8
{
9
    public function deleteAction($id)
10
    {
11
        $exam = (new ExamModel($this->get('dbh')))->getInfo($id);
12
13
        $this->render('admin-delete', [
14
            'title'   => 'Usuwanie testu',
15
            'content' => 'Czy na pewno chcesz usunąć '.$exam['title'].'?',
16
        ]);
17
    }
18
19
    public function postDeleteAction($examID)
20
    {
21
        $delModel = new ExamDeleteModel($this->get('dbh'));
22
23
        if ($delModel->delete($examID)) {
24
            $this->redirectWithMessage('/admin', 'success', 'Usunięto pomyślnie!');
25
        } else {
26
            $this->redirectWithMessage('/admin/test/del/'.$examID, 'warning', 'Coś się zepsuło!');
27
        }
28
    }
29
}
30