Hello. I am new in CakePHP 3. Recently I cake bake a table named CmleLanguages. The add, edit, index as well as view cake templates are generated in src. But I do not understand the
codes of CmleLanguages controller. The code segment is below:
class CmleLanguagesController extends AppController { public function index() { $cmleLanguages = $this->paginate($this->CmleLanguages); $this->set(compact('cmleLanguages')); } public function view($id = null) { $cmleLanguage = $this->CmleLanguages->get($id, [ 'contain' => [] ]); $this->set('cmleLanguage', $cmleLanguage); } public function add() { $cmleLanguage = $this->CmleLanguages->newEntity(); if ($this->request->is('post')) { $cmleLanguage = $this->CmleLanguages->patchEntity($cmleLanguage, $this->request->getData()); if ($this->CmleLanguages->save($cmleLanguage)) { $this->Flash->success(__('The cmle language has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('The cmle language could not be saved. Please, try again.')); } $this->set(compact('cmleLanguage')); } public function edit($id = null) { $cmleLanguage = $this->CmleLanguages->get($id, [ 'contain' => [] ]); if ($this->request->is(['patch', 'post', 'put'])) { $cmleLanguage = $this->CmleLanguages->patchEntity($cmleLanguage, $this->request->getData()); if ($this->CmleLanguages->save($cmleLanguage)) { $this->Flash->success(__('The cmle language has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('The cmle language could not be saved. Please, try again.')); } $this->set(compact('cmleLanguage')); } public function delete($id = null) { $this->request->allowMethod(['post', 'delete']); $cmleLanguage = $this->CmleLanguages->get($id); if ($this->CmleLanguages->delete($cmleLanguage)) { $this->Flash->success(__('The cmle language has been deleted.')); } else { $this->Flash->error(__('The cmle language could not be deleted. Please, try again.')); } return $this->redirect(['action' => 'index']); } }
Now I am wanting to understand line by line code so that I can realize how these codes are working.
Is there any resource about it?
Thanks.