You are here

protected function PubSubHubbub::subscribe in Feeds 8.3

Subscribes a subscription to 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 subscribe.

1 call to PubSubHubbub::subscribe()
PubSubHubbub::onPostFetch in src/EventSubscriber/PubSubHubbub.php
Subscribes to a feed.

File

src/EventSubscriber/PubSubHubbub.php, line 136

Class

PubSubHubbub
Event listener for PubSubHubbub subscriptions.

Namespace

Drupal\feeds\EventSubscriber

Code

protected function subscribe(FeedInterface $feed, SubscriptionInterface $subscription) {
  $subscription
    ->subscribe();
  $batch = [
    'title' => $this
      ->t('Subscribing to: %title', [
      '%title' => $feed
        ->label(),
    ]),
    'init_message' => $this
      ->t('Subscribing to: %title', [
      '%title' => $feed
        ->label(),
    ]),
    'operations' => [
      [
        'Drupal\\feeds\\EventSubscriber\\PubSubHubbub::runSubscribeBatch',
        [
          $subscription,
        ],
      ],
    ],
    'progress_message' => $this
      ->t('Subscribing: %title', [
      '%title' => $feed
        ->label(),
    ]),
    'error_message' => $this
      ->t('An error occored while subscribing to %title.', [
      '%title' => $feed
        ->label(),
    ]),
  ];
  $this
    ->batchSet($batch);
}