Passed
Pull Request — master (#8)
by Brian
06:08
created

AppController::thankyou()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * AppController
5
 */
6
7
namespace Fr3nch13\Jira\Controller;
8
9
use App\Controller\AppController as BaseController;
10
11
/**
12
 * App Controller
13
 *
14
 * The base controller for the jira plugin.
15
 *
16
 * -----------------------------
17
 * Inherited:
18
 *
19
 * {@inheritdoc}
20
 */
21
class AppController extends BaseController
22
{
23
    /**
24
     * Human name of this object.
25
     * @var string
26
     */
27
    public $humanName = '';
28
29
    /**
30
     * The form object.
31
     * @var object|null
32
     */
33
    public $JiraForm = null;
34
35
    /**
36
     * The html form.
37
     *
38
     * @return void|\Cake\Http\Response|null Redirects on success.
39
     */
40
    public function add()
41
    {
42
        $errors = [];
43
        if ($this->getRequest()->is('post')) {
44
            if ($this->JiraForm->execute($this->getRequest()->getData())) {
45
                $this->Flash->success(__('The {0} has been saved.', [$this->humanName]));
46
47
                return $this->redirect(['action' => 'thankyou', '?' => ['type' => $this->humanName]]);
48
            } else {
49
                $errors = $this->JiraForm->getErrors();
50
                $this->Flash->error(__('There was a problem saving the {0}.', [$this->humanName]));
51
            }
52
        }
53
54
        if ($this->getRequest()->is('get')) {
55
            $this->JiraForm->setData($this->JiraForm->getFormData());
56
        }
57
58
        $this->set([
59
            'form' => $this->JiraForm,
60
            'errors' => $errors
61
        ]);
62
    }
63
64
    /**
65
     * The thank you page after they've submitted their report.
66
     *
67
     * @return void
68
     */
69
    public function thankyou()
70
    {
71
        //
72
    }
73
}
74