| @@ 63-76 (lines=14) @@ | ||
| 60 | $this->BlogArticles->locale(I18n::defaultLocale()); |
|
| 61 | $article = $this->BlogArticles->newEntity($this->request->data); |
|
| 62 | ||
| 63 | if ($this->request->is('post')) { |
|
| 64 | $article->user_id = $this->Auth->user('id'); |
|
| 65 | $article->setTranslations($this->request->data); |
|
| 66 | ||
| 67 | if ($this->BlogArticles->save($article)) { |
|
| 68 | $this->eventManager()->attach(new Statistics()); |
|
| 69 | $event = new Event('Model.BlogArticles.new'); |
|
| 70 | $this->eventManager()->dispatch($event); |
|
| 71 | ||
| 72 | $this->Flash->success(__d('admin', 'Your article has been created successfully !')); |
|
| 73 | ||
| 74 | return $this->redirect(['action' => 'index']); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| 78 | $categories = $this->BlogArticles->BlogCategories->find('list'); |
|
| 79 | ||
| @@ 50-64 (lines=15) @@ | ||
| 47 | $this->Groups->locale(I18n::defaultLocale()); |
|
| 48 | $group = $this->Groups->newEntity($this->request->data); |
|
| 49 | ||
| 50 | if ($this->request->is('post')) { |
|
| 51 | $group->setTranslations($this->request->data); |
|
| 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->data()); |
|
| 93 | $group->setTranslations($this->request->data); |
|
| 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 | } |
|