You are here

public function FeedClearHandler::startBatchClear in Feeds 8.3

File

src/FeedClearHandler.php, line 17

Class

FeedClearHandler
Deletes the items of a feed.

Namespace

Drupal\feeds

Code

public function startBatchClear(FeedInterface $feed) {
  $feed
    ->lock();
  $feed
    ->clearStates();
  $batch = [
    'title' => $this
      ->t('Deleting items from: %title', [
      '%title' => $feed
        ->label(),
    ]),
    'init_message' => $this
      ->t('Deleting items from: %title', [
      '%title' => $feed
        ->label(),
    ]),
    'operations' => [
      [
        [
          $this,
          'clear',
        ],
        [
          $feed,
        ],
      ],
    ],
    'progress_message' => $this
      ->t('Deleting items from: %title', [
      '%title' => $feed
        ->label(),
    ]),
    'error_message' => $this
      ->t('An error occored while clearing %title.', [
      '%title' => $feed
        ->label(),
    ]),
  ];
  $this
    ->batchSet($batch);
}