Delete method

@param string|null $id User id.
@return void|\Cake\Network\Respose
@throws \Cake\Network\Exception\NotFoundException Exception if the user couldn't be found.
324547
public function delete($id = null)
    {
        $user = $this->Users->get($id);
        $this->request->allowMethod(['post', 'delete']);

        if ($this->Users->delete($user)) {
            $this->Flash->success(__('The user has been deleted.'));
        } else {
            $this->Flash->error(__('The user could not be deleted. Please, try again.'));
        }

        return $this->redirect(['action' => 'index']);
    }
235434
public function handleDelete(int $id): void
	{
		if ($this->isAjax()) {
			$page = $this->orm->pages->getById($id);
			$parent = $page->parent;
			$this->orm->pages->removeAndFlush($page);
			if ($parent !== null) {
				$this['list']->setDataSource($this->orm->pages->findById($parent->id));
				$this['list']->redrawItem($parent->id);
			} else {
				$this['list']->redrawControl();
			}
		} else {
			$this->terminate();
		}
	}
283691
public function delete($id = null)
    {
        // This allows for delete based on the primary key
        if ($id && !$this->exists) {
            $this->setAttribute($this->getKeyName(), $id);
            $this->exists = true;
        }

        // Can't delete something that doesn't exists
        if ($this->exists) {
            if ($this->fireModelEvent('deleting') === false) {
                return false;
            }

            $this->performDeleteOnModel();

            $this->exists = false;

            // Once the model has been deleted, we will fire off the deleted event so that
            // the developers may hook into post-delete operations. We will then return
            // a boolean true as the delete is presumably successful on the database.
            $this->fireModelEvent('deleted', false);

            return true;
        }

        return false;
    }
587677
public function actionDelete($id = null)
    {
        $model = User::find()->where(['id' => $id])->limit(1)->one();
        if (empty($model)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find Member with this ID.'));
            return $this->redirect(['admin/members']);
        }
        if ($model->id == User::loggedId()) {
            $this->error(Yii::t('podium/flash', 'Sorry! You can not delete your own account.'));
            return $this->redirect(['admin/members']);
        }
        if ($model->delete()) {
            PodiumCache::clearAfter('userDelete');
            Activity::deleteUser($model->id);
            Log::info('User deleted', $model->id, __METHOD__);
            $this->success(Yii::t('podium/flash', 'User has been deleted.'));
        } else {
            Log::error('Error while deleting user', $model->id, __METHOD__);
            $this->error(Yii::t('podium/flash', 'Sorry! There was some error while deleting the user.'));
        }
        return $this->redirect(['admin/members']);
    }
558814
public function delete($id = null)
    {
        if (!is_null($id)) {
            $this->setId($id);
        }

        return $this->getDbGateway()->delete($this->getId());
    }
1318892
public function delete($id = null) {
		$this->Printer->id = $id;
		if (!$this->Printer->exists($id)) {
			throw new NotFoundException(__('Invalid printer'));
		}
		if ($this->Printer->delete()) {
            $this->Printer->modificaImpresoraProductos($id);
			$this->Session->setFlash(__('The printer has been deleted.'));
		} 
	   else {
			$this->Session->setFlash(__('The printer could not be deleted. Please, try again.'));
		}
		return $this->redirect(array('action' => 'index'));
	}
779906
public static function logout($id = null)
    {
        if (!$id) $id = \Zend_Auth::getInstance()->getIdentity();
        if (!$id) return;
        self::getDbConnection()->executeQuery("DELETE FROM users_auth WHERE user_id=".$id['user_id']." and uniq='".$id['uniq']."'");
        \Zend_Auth::getInstance()->clearIdentity();
		\Zend_Session::forgetMe();		
    }
328584
public function delete($id = null)
    {
        $this->request->allowMethod(['post', 'delete']);

        $category = $this->PagesCategories->get($id);

        //Before deleting, it checks if the category has some pages
        if (!$category->page_count) {
            $this->PagesCategories->deleteOrFail($category);
            $this->Flash->success(I18N_OPERATION_OK);
        } else {
            $this->Flash->alert(I18N_BEFORE_DELETE);
        }

        return $this->redirect(['action' => 'index']);
    }
240763
public function delete($id)
    {
        $id = (int) $id;
        if ($id <= 0) {
            throw new Exception('Invalid param id');
        }
        return $this->rest->delete("$this->action/$id");
    }
401518
public function actionDelete($id)
    {
        if (Yii::$app->request->isAjax) {
            try {
                $this->service->remove($id);
                $this->output['status'] = 1;
            } catch (YiiException $e) {
                $this->output['errors'] = (array) $e->data;
            }
        }
    }
1338678
public function delete($id)
    {
        $this->loadModel('User.Roles');
        $role = $this->Roles->get($id);

        if (!in_array($role->id, [ROLE_ID_ADMINISTRATOR, ROLE_ID_AUTHENTICATED, ROLE_ID_ANONYMOUS])) {
            if ($this->Roles->delete($role)) {
                $this->Flash->success(__d('user', 'Role was successfully removed!'));
            } else {
                $this->Flash->danger(__d('user', 'Role could not be removed'));
            }
        } else {
            $this->Flash->danger(__d('user', 'This role cannot be deleted!'));
        }

        $this->title(__d('user', 'Remove User Role'));
        $this->redirect($this->referer());
    }
147401
public function delete(string $id)
    {
        $this->request->allowMethod('delete');

        $entity = $this->SavedSearches->find()
            ->enableHydration(true)
            ->where(['id' => $id])
            ->first();

        $success = false;
        if (null !== $entity) {
            Assert::isInstanceOf($entity, EntityInterface::class);
            $success = $this->SavedSearches->delete($entity);
        }

        $this->set('success', $success);
        $success ?
            $this->set('data', []) :
            $this->set('error', 'The saved search could not be deleted. Please, try again.');
        $this->set('_serialize', ['success', 'data', 'error']);
    }
699068
public function delete($id)
    {
        if (!$this->request->is('post')) {
            throw new MethodNotAllowedException();
        }

        /** @var Language $language */
        $language = $this->Languages->get($id);
        if ($this->Languages->delete($language)) {
            $this->Flash->success(__d('wasabi_core', 'The language <strong>{0}</strong> has been deleted.', $language->name));
        } else {
            $this->Flash->error($this->dbErrorMessage);
        }
        $this->redirect(['action' => 'index']);
        //@codingStandardIgnoreStart
        return;
        //@codingStandardIgnoreEnd
    }
293169
public function delete($id = null) {
        $this->request->allowMethod(['post', 'delete']);
        $cmsContentMeta = $this->CmsContentMeta->get($id);
        if ($this->CmsContentMeta->delete($cmsContentMeta)) {
            $this->Flash->success('The cms content Meta has been deleted.');
        } else {
            $this->Flash->error('The cms content Meta could not be deleted. Please, try again.');
        }
        return $this->redirect(['action' => 'index']);
    }
84838
public function delete(string $id = null)
    {
        $this->request->allowMethod(['post', 'delete']);
        $data = $this->request->getData();
        $permission = $this->Permissions->get($id);
        if ($this->Permissions->delete($permission)) {
            $this->Flash->success((string)__('The  permission has been deleted.'));
        } else {
            $this->Flash->error((string)__('The  permission could not be deleted. Please, try again.'));
        }

        $this->redirect($this->referer());
    }
218692
public function delete($id = null)
    {
        $this->request->allowMethod(['post', 'delete']);

        $photo = $this->Photos->get($id);
        $this->Photos->deleteOrFail($photo);
        $this->Flash->success(I18N_OPERATION_OK);

        return $this->redirect(['action' => 'index', $photo->album_id]);
    }
549220
public function delete($id = null) {
		$this->UnidadDeMedida->id = $id;
		if (!$this->UnidadDeMedida->exists()) {
			throw new NotFoundException(__('Unidad De Medida Inválido'));
		}
		$this->request->allowMethod('post', 'delete');
		if ($this->UnidadDeMedida->delete()) {
			$this->Flash->success(__('Se ha borrado la Unidad de Medida.'));
		} else {
			$this->Flash->error(__('No se ha podido eliminar la Unidad de Medida'), 'Risto.flash_error');
		}
		return $this->redirect($this->referer());
	}