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