Passed
Branch master (44bfae)
by giu
03:41
created

SiteoptionsController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 5
cp 0
crap 2
rs 10
1
<?php
2
namespace App\Controller;
3
4
use App\Controller\AppController;
5
6
/**
7
 * Siteoptions Controller
8
 *
9
 * @property \App\Model\Table\SiteoptionsTable $Siteoptions
10
 */
11
class SiteoptionsController extends AppController
12
{
13
14
    /**
15
     * Index method
16
     *
17
     * @return \Cake\Network\Response|null
18
     */
19
    public function index()
20
    {
21
        $siteoptions = $this->paginate($this->Siteoptions);
22
23
        $this->set(compact('siteoptions'));
24
        $this->set('_serialize', ['siteoptions']);
25
    }
26
27
    /**
28
     * View method
29
     *
30
     * @param string|null $id Siteoption id.
31
     * @return \Cake\Network\Response|null
32
     * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
33
     */
34
    public function view($id = null)
35
    {
36
        $siteoption = $this->Siteoptions->get($id, [
37
            'contain' => []
38
        ]);
39
40
        $this->set('siteoption', $siteoption);
41
        $this->set('_serialize', ['siteoption']);
42
    }
43
44
    /**
45
     * Add method
46
     *
47
     * @return \Cake\Network\Response|null Redirects on successful add, renders view otherwise.
48
     */
49
    public function add()
50
    {
51
        $siteoption = $this->Siteoptions->newEntity();
52
        if ($this->request->is('post')) {
53
            $siteoption = $this->Siteoptions->patchEntity($siteoption, $this->request->data);
0 ignored issues
show
Bug introduced by
It seems like $this->request->data can also be of type object; however, parameter $data of App\Model\Table\SiteoptionsTable::patchEntity() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

53
            $siteoption = $this->Siteoptions->patchEntity($siteoption, /** @scrutinizer ignore-type */ $this->request->data);
Loading history...
Deprecated Code introduced by
The property Cake\Http\ServerRequest::$data has been deprecated: 3.4.0 This public property will be removed in 4.0.0. Use getData() instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

53
            $siteoption = $this->Siteoptions->patchEntity($siteoption, /** @scrutinizer ignore-deprecated */ $this->request->data);

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
54
            if ($this->Siteoptions->save($siteoption)) {
55
                $this->Flash->success(__('The siteoption has been saved.'));
56
57
                return $this->redirect(['action' => 'index']);
58
            }
59
            $this->Flash->error(__('The siteoption could not be saved. Please, try again.'));
60
        }
61
        $this->set(compact('siteoption'));
62
        $this->set('_serialize', ['siteoption']);
63
    }
64
65
    /**
66
     * Edit method
67
     *
68
     * @param string|null $id Siteoption id.
69
     * @return \Cake\Network\Response|null Redirects on successful edit, renders view otherwise.
70
     * @throws \Cake\Network\Exception\NotFoundException When record not found.
71
     */
72
    public function edit($id = null)
73
    {
74
        $siteoption = $this->Siteoptions->get($id, [
75
            'contain' => []
76
        ]);
77
        if ($this->request->is(['patch', 'post', 'put'])) {
78
            $siteoption = $this->Siteoptions->patchEntity($siteoption, $this->request->data);
0 ignored issues
show
Bug introduced by
It seems like $this->request->data can also be of type object; however, parameter $data of App\Model\Table\SiteoptionsTable::patchEntity() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

78
            $siteoption = $this->Siteoptions->patchEntity($siteoption, /** @scrutinizer ignore-type */ $this->request->data);
Loading history...
Deprecated Code introduced by
The property Cake\Http\ServerRequest::$data has been deprecated: 3.4.0 This public property will be removed in 4.0.0. Use getData() instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

78
            $siteoption = $this->Siteoptions->patchEntity($siteoption, /** @scrutinizer ignore-deprecated */ $this->request->data);

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
79
            if ($this->Siteoptions->save($siteoption)) {
80
                $this->Flash->success(__('The siteoption has been saved.'));
81
82
                return $this->redirect(['action' => 'index']);
83
            }
84
            $this->Flash->error(__('The siteoption could not be saved. Please, try again.'));
85
        }
86
        $this->set(compact('siteoption'));
87
        $this->set('_serialize', ['siteoption']);
88
    }
89
90
    /**
91
     * Delete method
92
     *
93
     * @param string|null $id Siteoption id.
94
     * @return \Cake\Network\Response|null Redirects to index.
95
     * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
96
     */
97
    public function delete($id = null)
98
    {
99
        $this->request->allowMethod(['post', 'delete']);
100
        $siteoption = $this->Siteoptions->get($id);
101
        if ($this->Siteoptions->delete($siteoption)) {
102
            $this->Flash->success(__('The siteoption has been deleted.'));
103
        } else {
104
            $this->Flash->error(__('The siteoption could not be deleted. Please, try again.'));
105
        }
106
107
        return $this->redirect(['action' => 'index']);
108
    }
109
}
110