pictcode / lib / Cake / Test / bake_compare / Controller / ActionsWithNoSessions.ctp @ d37b000c
履歴 | 表示 | アノテート | ダウンロード (2.224 KB)
| 1 | 635eef61 | spyder1211 | |
|---|---|---|---|
| 2 | /** |
||
| 3 | * index method |
||
| 4 | * |
||
| 5 | * @return void |
||
| 6 | */ |
||
| 7 | public function index() {
|
||
| 8 | $this->BakeArticle->recursive = 0; |
||
| 9 | $this->set('bakeArticles', $this->Paginator->paginate());
|
||
| 10 | } |
||
| 11 | |||
| 12 | /** |
||
| 13 | * view method |
||
| 14 | * |
||
| 15 | * @throws NotFoundException |
||
| 16 | * @param string $id |
||
| 17 | * @return void |
||
| 18 | */ |
||
| 19 | public function view($id = null) {
|
||
| 20 | if (!$this->BakeArticle->exists($id)) {
|
||
| 21 | throw new NotFoundException(__('Invalid bake article'));
|
||
| 22 | } |
||
| 23 | $options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
|
||
| 24 | $this->set('bakeArticle', $this->BakeArticle->find('first', $options));
|
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * add method |
||
| 29 | * |
||
| 30 | * @return void |
||
| 31 | */ |
||
| 32 | public function add() {
|
||
| 33 | if ($this->request->is('post')) {
|
||
| 34 | $this->BakeArticle->create(); |
||
| 35 | if ($this->BakeArticle->save($this->request->data)) {
|
||
| 36 | return $this->flash(__('The bake article has been saved.'), array('action' => 'index'));
|
||
| 37 | } |
||
| 38 | } |
||
| 39 | $bakeTags = $this->BakeArticle->BakeTag->find('list');
|
||
| 40 | $this->set(compact('bakeTags'));
|
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * edit method |
||
| 45 | * |
||
| 46 | * @throws NotFoundException |
||
| 47 | * @param string $id |
||
| 48 | * @return void |
||
| 49 | */ |
||
| 50 | public function edit($id = null) {
|
||
| 51 | if (!$this->BakeArticle->exists($id)) {
|
||
| 52 | throw new NotFoundException(__('Invalid bake article'));
|
||
| 53 | } |
||
| 54 | if ($this->request->is(array('post', 'put'))) {
|
||
| 55 | if ($this->BakeArticle->save($this->request->data)) {
|
||
| 56 | return $this->flash(__('The bake article has been saved.'), array('action' => 'index'));
|
||
| 57 | } |
||
| 58 | } else {
|
||
| 59 | $options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
|
||
| 60 | $this->request->data = $this->BakeArticle->find('first', $options);
|
||
| 61 | } |
||
| 62 | $bakeTags = $this->BakeArticle->BakeTag->find('list');
|
||
| 63 | $this->set(compact('bakeTags'));
|
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * delete method |
||
| 68 | * |
||
| 69 | * @throws NotFoundException |
||
| 70 | * @param string $id |
||
| 71 | * @return void |
||
| 72 | */ |
||
| 73 | public function delete($id = null) {
|
||
| 74 | $this->BakeArticle->id = $id; |
||
| 75 | if (!$this->BakeArticle->exists()) {
|
||
| 76 | throw new NotFoundException(__('Invalid bake article'));
|
||
| 77 | } |
||
| 78 | $this->request->allowMethod('post', 'delete');
|
||
| 79 | if ($this->BakeArticle->delete()) {
|
||
| 80 | return $this->flash(__('The bake article has been deleted.'), array('action' => 'index'));
|
||
| 81 | } else {
|
||
| 82 | return $this->flash(__('The bake article could not be deleted. Please, try again.'), array('action' => 'index'));
|
||
| 83 | } |
||
| 84 | } |