You are here

protected function SubscriptionController::handleUnsubscribe in Feeds 8.3

Handles an unsubscribe request.

Parameters

int $subscription_id: The subscription entity id.

string $token: The subscription token.

\Symfony\Component\HttpFoundation\Request $request: The request object.

Return value

\Symfony\Component\HttpFoundation\Response The response challenge.

Throws

\Symfony\Component\HttpKernel\Exception\NotFoundHttpException Thrown if anything seems amiss.

1 call to SubscriptionController::handleUnsubscribe()
SubscriptionController::subscribe in src/Controller/SubscriptionController.php
Handles subscribe/unsubscribe requests.

File

src/Controller/SubscriptionController.php, line 142

Class

SubscriptionController
Returns responses for PuSH module routes.

Namespace

Drupal\feeds\Controller

Code

protected function handleUnsubscribe($subscription_id, $token, Request $request) {

  // The subscription id already deleted, but waiting in the keyvalue store.
  $id = $token . ':' . $subscription_id;
  $subscription = $this->keyValueExpireFactory
    ->get('feeds_push_unsubscribe')
    ->get($id);
  if (!$subscription) {
    throw new NotFoundHttpException();
  }
  $this->keyValueExpireFactory
    ->get('feeds_push_unsubscribe')
    ->delete($id);
  return new Response(Html::escape($request->query
    ->get('hub_challenge')), 200);
}