You are here

public function DisqusComment::rollback in Disqus 8

Delete the specified destination object from the target Drupal.

Parameters

array $destination_identifier: The ID of the destination object to delete.

Overrides DestinationBase::rollback

File

src/Plugin/migrate/destination/DisqusComment.php, line 176

Class

DisqusComment
Disqus comment destination.

Namespace

Drupal\disqus\Plugin\migrate\destination

Code

public function rollback(array $destination_identifier) {
  $disqus = disqus_api();
  if ($disqus) {
    try {
      $post = $disqus->posts
        ->details([
        'post' => $destination_identifier['disqus_id'],
      ]);
    } catch (\Exception $exception) {
      $this->logger
        ->error('Error loading thread details for entity : @identifier. Check your API keys.', [
        '@identifier' => $destination_identifier['disqus_id'],
      ]);
      $post = NULL;
    }
    if (!isset($post->id)) {
      $this->logger
        ->notice('Unable to find post: @identifier when trying to delete it. Maybe it was already deleted?', [
        '@identifier' => $destination_identifier['disqus_id'],
      ]);
      return;
    }
    try {
      $disqus->posts
        ->remove([
        'access_token' => $this->config
          ->get('advanced.disqus_useraccesstoken'),
        'post' => $destination_identifier['disqus_id'],
      ]);
    } catch (\Exception $exception) {
      $this->logger
        ->error('Error deleting post @identifier.', [
        '@identifier' => $destination_identifier['disqus_id'],
      ]);
    }
    return FALSE;
  }
}