You are here

public function XmlSitemapLinkStorage::updateMultiple in XML sitemap 2.x

Same name and namespace in other branches
  1. 8 src/XmlSitemapLinkStorage.php \Drupal\xmlsitemap\XmlSitemapLinkStorage::updateMultiple()

Perform a mass update of sitemap data.

If visible links are updated, this will automatically set the regenerate needed flag to TRUE.

Parameters

array $updates: An array of values to update fields to, keyed by field name.

array $conditions: An array of values to match keyed by field.

bool $check_flag: An bool with check flag.

Return value

int The number of links that were updated.

Overrides XmlSitemapLinkStorageInterface::updateMultiple

File

src/XmlSitemapLinkStorage.php, line 300

Class

XmlSitemapLinkStorage
XmlSitemap link storage service class.

Namespace

Drupal\xmlsitemap

Code

public function updateMultiple(array $updates = [], array $conditions = [], $check_flag = TRUE) {

  // If we are going to modify a visible sitemap link, we will need to set
  // the regenerate needed flag.
  if ($check_flag && !$this->state
    ->get('xmlsitemap_regenerate_needed')) {
    $this
      ->checkChangedLinks($conditions, $updates, TRUE);
  }

  // Process updates.
  $query = $this->connection
    ->update('xmlsitemap');
  $query
    ->fields($updates);
  foreach ($conditions as $field => $value) {
    $operator = is_array($value) ? 'IN' : '=';
    $query
      ->condition($field, $value, $operator);
  }
  return $query
    ->execute();
}