-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
Actions.ctp
89 lines (84 loc) · 2.44 KB
/
Actions.ctp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Index method
*
* @return void
*/
public function index() {
$this->paginate = [
'contain' => ['BakeUsers']
];
$this->set('bakeArticles', $this->paginate($this->BakeArticles));
}
/**
* View method
*
* @param string $id
* @return void
* @throws \Cake\Network\Exception\NotFoundException
*/
public function view($id = null) {
$bakeArticle = $this->BakeArticles->get($id, [
'contain' => ['BakeUsers', 'BakeTags', 'BakeComments']
]);
$this->set('bakeArticle', $bakeArticle);
}
/**
* Add method
*
* @return void
*/
public function add() {
$bakeArticle = $this->BakeArticles->newEntity($this->request->data);
if ($this->request->is('post')) {
if ($this->BakeArticles->save($bakeArticle)) {
$this->Flash->success('The bake article has been saved.');
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error('The bake article could not be saved. Please, try again.');
}
}
$bakeUsers = $this->BakeArticles->BakeUsers->find('list');
$bakeTags = $this->BakeArticles->BakeTags->find('list');
$this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags'));
}
/**
* Edit method
*
* @param string $id
* @return void
* @throws \Cake\Network\Exception\NotFoundException
*/
public function edit($id = null) {
$bakeArticle = $this->BakeArticles->get($id, [
'contain' => ['BakeTags']
]);
if ($this->request->is(['patch', 'post', 'put'])) {
$bakeArticle = $this->BakeArticles->patchEntity($bakeArticle, $this->request->data);
if ($this->BakeArticles->save($bakeArticle)) {
$this->Flash->success('The bake article has been saved.');
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error('The bake article could not be saved. Please, try again.');
}
}
$bakeUsers = $this->BakeArticles->BakeUsers->find('list');
$bakeTags = $this->BakeArticles->BakeTags->find('list');
$this->set(compact('bakeArticle', 'bakeUsers', 'bakeTags'));
}
/**
* Delete method
*
* @param string $id
* @return void
* @throws \Cake\Network\Exception\NotFoundException
*/
public function delete($id = null) {
$bakeArticle = $this->BakeArticles->get($id);
$this->request->allowMethod(['post', 'delete']);
if ($this->BakeArticles->delete($bakeArticle)) {
$this->Flash->success('The bake article has been deleted.');
} else {
$this->Flash->error('The bake article could not be deleted. Please, try again.');
}
return $this->redirect(['action' => 'index']);
}