/** * Delete action. * * @param string|null $id Menu id. * @return void Redirects to index. * @throws \Cake\Network\Exception\NotFoundException When record not found. */ public function delete($id = null) { $this->request->allowMethod(['post', 'delete']); $controllerName = Inflector::singularize($this->name); $lowerController = mb_strtolower($controllerName); $record = $this->{$this->name}->get($id); $domain = Plugin::getPluginName($this->plugin); if ($this->{$this->name}->delete($record)) { $this->Flash->success(__d($domain, 'The {0} has been deleted.', $lowerController)); } else { $this->Flash->error(__d($domain, 'The {0} could not be deleted. Please, try again.', $lowerController)); } return $this->redirect(['action' => 'index']); }