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

ExamDelete::deleteAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
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