Map Laravel's soft delete action to Kinvey's user suspend
endpoint.

@param  Guzzle\Common\Event
@return void
438884
public function beforePrepare(Event $event)
	{
		$command = $event['command'];
		$operation = $command->getOperation();
		$client = $command->getClient();

		if ($command->getName() !== 'updateEntity') return;
		if ($operation->getParam('collection')->getDefault() !== 'user') return;

		// Attempt to get the model's deleted at value from the array of values passed
		// to the command.
		$statusValue = false;

		if ($command->offsetExists(Model::DELETED_AT))
		{
			$statusValue = $command->offsetGet(Model::DELETED_AT);
		}
		elseif ($command->offsetExists('_kmd'))
		{
			$_kmd = array_dot($command->offsetGet('_kmd'));

			$statusField = MODEL::DELETED_AT;
			$statusField = str_replace('_kmd.', '', MODEL::DELETED_AT);

			if (array_key_exists($statusField, $_kmd))
			{
				$statusValue = $_kmd[$statusField];
			}
		}

		// Could not determine the status field.
		if ($statusValue === false)
		{
			return;
		}
		// Suspend the user.
		elseif (!is_null($statusValue))
		{
			$event->stopPropagation();

			$suspendCommand = $client->getCommand('deleteEntity', array(
				'collection' => 'user',
				'_id' => $command->offsetGet('_id'),
			));
			$suspendCommand->execute();
		}
		// Restore.
		else
		{
			$event->stopPropagation();

			$restoreCommand = $client->getCommand('restore', array(
				'_id' => $command->offsetGet('_id'),
			));
			$restoreCommand->execute();
		}
	}
18014
public function onDelete()
    {
        $this->validateRequestTheme();

        $type = Request::input('templateType');

        $this->loadTemplate($type, trim(Request::input('templatePath')))->delete();

        /*
         * Extensibility - documented above
         */
        $this->fireSystemEvent('cms.template.delete', [$type]);
    }
850881
public function onKernelRequest(GetResponseEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        $currentRoute = $request->attributes->get('_route', '');
        if (mb_stripos($currentRoute, self::ADMIN_ROUTE_PREFIX) !== 0) {
            return;
        }

        $request->attributes->set(self::ADMIN_FLAG_NAME, true);

        $adminEvent = new AdminMatchEvent($event->getRequest(), $event->getRequestType());
        $this->eventDispatcher->dispatch($adminEvent, BlockManagerAdminEvents::ADMIN_MATCH);
    }
565990
public function destroy(Event $event)
    {
        $this->authorize('delete', $event);
        $event->deleteUsers($event->users);
        $event->delete();

        return redirect()->route('laralum::events.index')
            ->with('success', __('laralum_events::general.event_deleted', ['id' => $event->id]));
    }
730519
public function onPasswordReset(PostPasswordResetEvent $event): void
    {
        $user = $event->getUser();

        $this->mailHelper
            ->sendMail(
                [$user->email => $this->getUserName($user)],
                'ngsite.user.forgot_password.password_changed.subject',
                $this->configResolver->getParameter('template.user.mail.forgot_password_password_changed', 'ngsite'),
                [
                    'user' => $user,
                ]
            );

        $this->ezUserAccountKeyRepository->removeByUserId($user->id);
    }
570076
public function afterDelete()
    {
        if ($this->isSoftDelete()) {
            Event::fire('rainlab.user.deactivate', [$this]);
            return;
        }

        $this->avatar && $this->avatar->delete();

        parent::afterDelete();
    }
232102
protected function performDeleteOnModel()
	{
		$query = $this->newQuery()->where($this->getKeyName(), $this->getKey());

		if ($this->softDelete)
		{
			$this->{static::DELETED_AT} = $time = $this->freshTimestamp();

			$query->update(array(static::DELETED_AT => $this->fromDateTime($time)));
		}
		else
		{
			$query->delete();
		}
	}
347803
public function onKernelRequest(GetResponseEvent $event)
    {
        if (!$event->getRequest()->attributes->get('is_rest_request')) {
            return;
        }

        if (!$this->csrfEnabled) {
            return;
        }

        // skip CSRF validation if no session is running
        if (!$event->getRequest()->getSession()->isStarted()) {
            return;
        }

        if ($this->isMethodSafe($event->getRequest()->getMethod())) {
            return;
        }

        if ($this->isSessionRoute($event->getRequest()->get('_route'))) {
            return;
        }

        if (!$this->checkCsrfToken($event->getRequest())) {
            throw new UnauthorizedException(
                'Missing or invalid CSRF token',
                $event->getRequest()->getMethod() . ' ' . $event->getRequest()->getPathInfo()
            );
        }

        // Dispatching event so that CSRF token intention can be injected into Legacy Stack
        $this->eventDispatcher->dispatch(RestEvents::REST_CSRF_TOKEN_VALIDATED);
    }
1262180
private function action_delete()
    {
        $mbox = trim(rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true)); //UTF7-IMAP
        $user = trim(rcube_utils::get_input_value('_user', rcube_utils::INPUT_POST));

        $user = explode(',', $user);

        foreach ($user as $u) {
            $u = trim($u);
            if ($this->rc->storage->delete_acl($mbox, $u)) {
                $this->rc->output->command('acl_remove_row', rcube_utils::html_identifier($u));
            }
            else {
                $error = true;
            }
        }

        if (!$error) {
            $this->rc->output->show_message('acl.deletesuccess', 'confirmation');
        }
        else {
            $this->rc->output->show_message('acl.deleteerror', 'error');
        }
    }
116776
public function onKernelView(GetResponseForControllerResultEvent $event): void
    {
        $request = $event->getRequest();
        if ($request->isMethodSafe(false)) {
            return;
        }

        $resourceClass = $request->attributes->get('_api_resource_class');
        if (null === $resourceClass) {
            return;
        }

        $controllerResult = $event->getControllerResult();
        if (null === $objectManager = $this->getManager($resourceClass, $controllerResult)) {
            return;
        }

        switch ($request->getMethod()) {
            case 'POST':
                $objectManager->persist($controllerResult);
                break;
            case 'DELETE':
                $objectManager->remove($controllerResult);
                $event->setControllerResult(null);
                break;
        }

        $objectManager->flush();
    }
878426
public function delete($event)
    {
        $formName = $event->sender->formName();
        $primaryKey = $event->sender->primaryKey;

        $this->model::deleteAll([
            'model' => $formName,
            'model_id' => $primaryKey,
        ]);
    }
39635
public function handle(DeletingUser $event)
    {
        if ($event->user->isAdmin())
            return false;

        if ($event->user->isForceDeleting())
            $event->user->detachAllRoles(false);

        return true;
    }
583685
public function onDelete(DeleteResourceEvent $event)
    {
        /** @var Exercise $exercise */
        $exercise = $event->getResource();

        $deletable = $this->exerciseManager->isDeletable($exercise);
        if (!$deletable) {
            // If papers, the Exercise is not completely removed
            $event->enableSoftDelete();
        }

        $event->stopPropagation();
    }
692900
public function leave(Event $event)
    {
        $this->authorize('join', Event::class);
        $event->deleteUser(User::findOrfail(Auth::id()));

        return redirect()->route('laralum::events.index')
            ->with('success', __('laralum_events::general.left_event', ['id' => $event->id]));
    }
772312
public function onDelete(GenericDataEvent $event)
    {
        /** @var UserEntity[] $users */
        $users = $event->getData();

        $ids = [];
        foreach ($users as $user) {
            $ids[] = $user->getId();
        }

        $this->manager->removeTaggedObjectsByClassAndIds(UserEntity::class, $ids);
    }
251436
public function actionDelete()
	{
		if(Yii::app()->request->isPostRequest)
		{
			// we only allow deletion via POST request
			$this->loadModel()->delete();

			// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
			if(!isset($_POST['ajax']))
				$this->redirect(array('index'));
		}
		else
			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
	}
1040045
public function onKernelTerminate(PostResponseEvent $event)
    {
        if (!$event->getRequest()->hasSession()) {
            return;
        }

        $session = $event->getRequest()->getSession();

        $this->registry->refreshLastUsed($session->getId(), $session->getMetadataBag()->getLastUsed());
    }