/** * 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) { $this->->id = $id; if (!$this->->exists()) { throw new NotFoundException(__('Invalid ')); } $this->set('', $this->->read(null, $id)); } /** * 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) { $this->->id = $id; if (!$this->->exists()) { 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 { $this->request->data = $this->->read(null, $id); } {$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 MethodNotAllowedException * @throws NotFoundException * @param string $id * @return void */ public function delete($id = null) { if (!$this->request->is('post')) { throw new MethodNotAllowedException(); } $this->->id = $id; if (!$this->->exists()) { throw new NotFoundException(__('Invalid ')); } 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')); }