public function XmlSitemapLinkStorage::checkChangedLinks in XML sitemap 8
Same name and namespace in other branches
- 2.x src/XmlSitemapLinkStorage.php \Drupal\xmlsitemap\XmlSitemapLinkStorage::checkChangedLinks()
Check if there is a visible sitemap link given a certain set of conditions.
Parameters
array $conditions: An array of values to match keyed by field.
array $updates: Updates to be made.
bool $flag: An optional boolean that if TRUE, will set the regenerate needed flag if there is a match. Defaults to FALSE.
Return value
bool TRUE if there is a visible link, or FALSE otherwise.
Overrides XmlSitemapLinkStorageInterface::checkChangedLinks
2 calls to XmlSitemapLinkStorage::checkChangedLinks()
- XmlSitemapLinkStorage::deleteMultiple in src/
XmlSitemapLinkStorage.php - Delete multiple sitemap links from the database.
- XmlSitemapLinkStorage::updateMultiple in src/
XmlSitemapLinkStorage.php - Perform a mass update of sitemap data.
File
- src/
XmlSitemapLinkStorage.php, line 247
Class
- XmlSitemapLinkStorage
- XmlSitemap link storage service class.
Namespace
Drupal\xmlsitemapCode
public function checkChangedLinks(array $conditions = [], array $updates = [], $flag = FALSE) {
// If we are changing status or access, check for negative current values.
$conditions['status'] = !empty($updates['status']) && empty($conditions['status']) ? 0 : 1;
$conditions['access'] = !empty($updates['access']) && empty($conditions['access']) ? 0 : 1;
$query = $this->connection
->select('xmlsitemap');
$query
->addExpression('1');
foreach ($conditions as $field => $value) {
$operator = is_array($value) ? 'IN' : '=';
$query
->condition($field, $value, $operator);
}
$query
->range(0, 1);
$changed = $query
->execute()
->fetchField();
if ($changed && $flag) {
$this->state
->set('xmlsitemap_regenerate_needed', TRUE);
}
return $changed;
}