/** * index method * * @return void */ public function index() { $this->->recursive = 0; $this->set('', $this->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->Session->setFlash(__('The has been saved')); $this->redirect(array('action' => 'index')); $this->flash(__(' saved.'), array('action' => 'index')); } else { $this->Session->setFlash(__('The could not be saved. Please, try again.')); } } {$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('post') || $this->request->is('put')) { if ($this->->save($this->request->data)) { $this->Session->setFlash(__('The has been saved')); $this->redirect(array('action' => 'index')); $this->flash(__('The has been saved.'), array('action' => 'index')); } else { $this->Session->setFlash(__('The could not be saved. Please, try again.')); } } 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 * @throws MethodNotAllowedException * @param string $id * @return void */ public function delete($id = null) { $this->->id = $id; if (!$this->->exists()) { throw new NotFoundException(__('Invalid ')); } $this->request->onlyAllow('post', 'delete'); if ($this->->delete()) { $this->Session->setFlash(__(' deleted')); $this->redirect(array('action' => 'index')); $this->flash(__(' deleted'), array('action' => 'index')); } $this->Session->setFlash(__(' was not deleted')); $this->flash(__(' was not deleted'), array('action' => 'index')); $this->redirect(array('action' => 'index')); }