@@ 65-78 (lines=14) @@ | ||
62 | $this->BlogArticles->locale(I18n::defaultLocale()); |
|
63 | $article = $this->BlogArticles->newEntity($this->request->getParsedBody()); |
|
64 | ||
65 | if ($this->request->is('post')) { |
|
66 | $article->user_id = $this->Auth->user('id'); |
|
67 | $article->setTranslations($this->request->getParsedBody()); |
|
68 | ||
69 | if ($this->BlogArticles->save($article)) { |
|
70 | $this->eventManager()->attach(new Statistics()); |
|
71 | $event = new Event('Model.BlogArticles.new'); |
|
72 | $this->eventManager()->dispatch($event); |
|
73 | ||
74 | $this->Flash->success(__d('admin', 'Your article has been created successfully !')); |
|
75 | ||
76 | return $this->redirect(['action' => 'index']); |
|
77 | } |
|
78 | } |
|
79 | ||
80 | $categories = $this->BlogArticles->BlogCategories->find('list'); |
|
81 |
@@ 50-64 (lines=15) @@ | ||
47 | $this->Groups->locale(I18n::defaultLocale()); |
|
48 | $group = $this->Groups->newEntity($this->request->getParsedBody()); |
|
49 | ||
50 | if ($this->request->is('post')) { |
|
51 | $group->setTranslations($this->request->getParsedBody()); |
|
52 | ||
53 | if ($this->Groups->save($group)) { |
|
54 | //Event. |
|
55 | $this->eventManager()->attach(new Statistics()); |
|
56 | ||
57 | $stats = new Event('Model.Groups.update', $this); |
|
58 | $this->eventManager()->dispatch($stats); |
|
59 | ||
60 | $this->Flash->success(__d('admin', 'Your group has been created successfully !')); |
|
61 | ||
62 | return $this->redirect(['action' => 'index']); |
|
63 | } |
|
64 | } |
|
65 | ||
66 | $this->set(compact('group')); |
|
67 | } |
|
@@ 91-106 (lines=16) @@ | ||
88 | return $this->redirect(['action' => 'index']); |
|
89 | } |
|
90 | ||
91 | if ($this->request->is('put')) { |
|
92 | $this->Groups->patchEntity($group, $this->request->getParsedBody()); |
|
93 | $group->setTranslations($this->request->getParsedBody()); |
|
94 | ||
95 | if ($this->Groups->save($group)) { |
|
96 | //Event. |
|
97 | $this->eventManager()->attach(new Statistics()); |
|
98 | ||
99 | $stats = new Event('Model.Groups.update', $this); |
|
100 | $this->eventManager()->dispatch($stats); |
|
101 | ||
102 | $this->Flash->success(__d('admin', 'This group has been updated successfully !')); |
|
103 | ||
104 | return $this->redirect(['action' => 'index']); |
|
105 | } |
|
106 | } |
|
107 | ||
108 | $this->set(compact('group')); |
|
109 | } |