/** * index method * * @return void */ public function index() { $this->->recursive = 0; $this->set('', $this->Paginator->paginate()); } /** * view method * * @throws NotFoundException * @param string $id * @return void */ public function view($id = null) { if (!$this->->exists($id)) { throw new NotFoundException(__('Invalid ')); } $options = array('conditions' => array('.' . $this->->primaryKey => $id)); $this->set('', $this->->find('first', $options)); } /** * add method * * @return void */ public function add() { if ($this->request->is('post')) { $this->->create(); if ($this->->save($this->request->data)) { $this->Flash->success(__('The has been saved.')); return $this->redirect(array('action' => 'index')); } else { $this->Flash->error(__('The could not be saved. Please, try again.')); return $this->flash(__('The has been saved.'), array('action' => 'index')); } } {$assoc} as $associationName => $relation): if (!empty($associationName)): $otherModelName = $this->_modelName($associationName); $otherPluralName = $this->_pluralName($associationName); echo "\t\t\${$otherPluralName} = \$this->{$currentModelName}->{$otherModelName}->find('list');\n"; $compact[] = "'{$otherPluralName}'"; endif; endforeach; endforeach; if (!empty($compact)): echo "\t\t\$this->set(compact(".join(', ', $compact)."));\n"; endif; ?> } /** * edit method * * @throws NotFoundException * @param string $id * @return void */ public function edit($id = null) { if (!$this->->exists($id)) { throw new NotFoundException(__('Invalid ')); } if ($this->request->is(array('post', 'put'))) { if ($this->->save($this->request->data)) { $this->Flash->success(__('The has been saved.')); return $this->redirect(array('action' => 'index')); } else { $this->Flash->error(__('The could not be saved. Please, try again.')); return $this->flash(__('The has been saved.'), array('action' => 'index')); } } else { $options = array('conditions' => array('.' . $this->->primaryKey => $id)); $this->request->data = $this->->find('first', $options); } {$assoc} as $associationName => $relation): if (!empty($associationName)): $otherModelName = $this->_modelName($associationName); $otherPluralName = $this->_pluralName($associationName); echo "\t\t\${$otherPluralName} = \$this->{$currentModelName}->{$otherModelName}->find('list');\n"; $compact[] = "'{$otherPluralName}'"; endif; endforeach; endforeach; if (!empty($compact)): echo "\t\t\$this->set(compact(".join(', ', $compact)."));\n"; endif; ?> } /** * delete method * * @throws NotFoundException * @param string $id * @return void */ public function delete($id = null) { if (!$this->->exists($id)) { throw new NotFoundException(__('Invalid ')); } $this->request->allowMethod('post', 'delete'); if ($this->->delete($id)) { $this->Flash->success(__('The has been deleted.')); } else { $this->Flash->error(__('The could not be deleted. Please, try again.')); } return $this->redirect(array('action' => 'index')); return $this->flash(__('The has been deleted.'), array('action' => 'index')); } else { return $this->flash(__('The could not be deleted. Please, try again.'), array('action' => 'index')); } }