Passed
Push — 1.x-dev ( 2550bc...9e01db )
by Brian
04:33
created

AppController::thankyou()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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