You are here

protected function PubSubHubbub::unsubscribe in Feeds 8.3

Unsubscribes a subscription from a hub in a batch.

Parameters

\Drupal\feeds\FeedInterface $feed: The feed to which the subscription is linked.

\Drupal\feeds\SubscriptionInterface $subscription: The subscription to unsubscribe.

2 calls to PubSubHubbub::unsubscribe()
PubSubHubbub::onDeleteMultipleFeeds in src/EventSubscriber/PubSubHubbub.php
Deletes subscriptions when feeds are deleted.
PubSubHubbub::onPostFetch in src/EventSubscriber/PubSubHubbub.php
Subscribes to a feed.

File

src/EventSubscriber/PubSubHubbub.php, line 163

Class

PubSubHubbub
Event listener for PubSubHubbub subscriptions.

Namespace

Drupal\feeds\EventSubscriber

Code

protected function unsubscribe(FeedInterface $feed, SubscriptionInterface $subscription = NULL) {
  if (!$subscription) {
    return;
  }
  $subscription
    ->unsubscribe();
  $batch = [
    'title' => $this
      ->t('Unsubscribing from: %title', [
      '%title' => $feed
        ->label(),
    ]),
    'init_message' => $this
      ->t('Unsubscribing from: %title', [
      '%title' => $feed
        ->label(),
    ]),
    'operations' => [
      [
        'Drupal\\feeds\\EventSubscriber\\PubSubHubbub::runSubscribeBatch',
        [
          $subscription,
        ],
      ],
    ],
    'progress_message' => $this
      ->t('Unsubscribing: %title', [
      '%title' => $feed
        ->label(),
    ]),
    'error_message' => $this
      ->t('An error occored while unsubscribing from %title.', [
      '%title' => $feed
        ->label(),
    ]),
  ];
  $this
    ->batchSet($batch);
}