mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
90 lines
2.5 KiB
PHP
90 lines
2.5 KiB
PHP
|
|
/**
|
|
* index method
|
|
*
|
|
* @return void
|
|
*/
|
|
public function index() {
|
|
$this->BakeArticle->recursive = 0;
|
|
$this->set('bakeArticles', $this->Paginator->paginate());
|
|
}
|
|
|
|
/**
|
|
* view method
|
|
*
|
|
* @throws NotFoundException
|
|
* @param string $id
|
|
* @return void
|
|
*/
|
|
public function view($id = null) {
|
|
if (!$this->BakeArticle->exists($id)) {
|
|
throw new NotFoundException(__('Invalid bake article'));
|
|
}
|
|
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
|
|
$this->set('bakeArticle', $this->BakeArticle->find('first', $options));
|
|
}
|
|
|
|
/**
|
|
* add method
|
|
*
|
|
* @return void
|
|
*/
|
|
public function add() {
|
|
if ($this->request->is('post')) {
|
|
$this->BakeArticle->create();
|
|
if ($this->BakeArticle->save($this->request->data)) {
|
|
$this->Flash->success(__('The bake article has been saved.'));
|
|
return $this->redirect(array('action' => 'index'));
|
|
} else {
|
|
$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
|
|
}
|
|
}
|
|
$bakeTags = $this->BakeArticle->BakeTag->find('list');
|
|
$this->set(compact('bakeTags'));
|
|
}
|
|
|
|
/**
|
|
* edit method
|
|
*
|
|
* @throws NotFoundException
|
|
* @param string $id
|
|
* @return void
|
|
*/
|
|
public function edit($id = null) {
|
|
if (!$this->BakeArticle->exists($id)) {
|
|
throw new NotFoundException(__('Invalid bake article'));
|
|
}
|
|
if ($this->request->is(array('post', 'put'))) {
|
|
if ($this->BakeArticle->save($this->request->data)) {
|
|
$this->Flash->success(__('The bake article has been saved.'));
|
|
return $this->redirect(array('action' => 'index'));
|
|
} else {
|
|
$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
|
|
}
|
|
} else {
|
|
$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
|
|
$this->request->data = $this->BakeArticle->find('first', $options);
|
|
}
|
|
$bakeTags = $this->BakeArticle->BakeTag->find('list');
|
|
$this->set(compact('bakeTags'));
|
|
}
|
|
|
|
/**
|
|
* delete method
|
|
*
|
|
* @throws NotFoundException
|
|
* @param string $id
|
|
* @return void
|
|
*/
|
|
public function delete($id = null) {
|
|
if (!$this->BakeArticle->exists($id)) {
|
|
throw new NotFoundException(__('Invalid bake article'));
|
|
}
|
|
$this->request->allowMethod('post', 'delete');
|
|
if ($this->BakeArticle->delete($id)) {
|
|
$this->Flash->success(__('The bake article has been deleted.'));
|
|
} else {
|
|
$this->Flash->error(__('The bake article could not be deleted. Please, try again.'));
|
|
}
|
|
return $this->redirect(array('action' => 'index'));
|
|
}
|