You are here

public function XmlSitemapLinkStorage::deleteMultiple in XML sitemap 8

Same name and namespace in other branches
  1. 2.x src/XmlSitemapLinkStorage.php \Drupal\xmlsitemap\XmlSitemapLinkStorage::deleteMultiple()

Delete multiple sitemap links from the database.

If visible sitemap links were deleted, this will automatically set the regenerate needed flag.

Parameters

array $conditions: An array of conditions on the {xmlsitemap} table in the form 'field' => $value.

Return value

int The number of links that were deleted.

Overrides XmlSitemapLinkStorageInterface::deleteMultiple

1 call to XmlSitemapLinkStorage::deleteMultiple()
XmlSitemapLinkStorage::delete in src/XmlSitemapLinkStorage.php
Delete a specific sitemap link from the database.

File

src/XmlSitemapLinkStorage.php, line 282

Class

XmlSitemapLinkStorage
XmlSitemap link storage service class.

Namespace

Drupal\xmlsitemap

Code

public function deleteMultiple(array $conditions) {
  if (!$this->state
    ->get('xmlsitemap_regenerate_needed')) {
    $this
      ->checkChangedLinks($conditions, [], TRUE);
  }

  // @todo Add a hook_xmlsitemap_link_delete() hook invoked here.
  $query = $this->connection
    ->delete('xmlsitemap');
  foreach ($conditions as $field => $value) {
    $operator = is_array($value) ? 'IN' : '=';
    $query
      ->condition($field, $value, $operator);
  }
  return $query
    ->execute();
}