function xmlsitemap_get_link_type_indexed_status in XML sitemap 8
Same name and namespace in other branches
- 6.2 xmlsitemap.module \xmlsitemap_get_link_type_indexed_status()
- 7.2 xmlsitemap.module \xmlsitemap_get_link_type_indexed_status()
- 2.x xmlsitemap.module \xmlsitemap_get_link_type_indexed_status()
Returns statistics about specific entity links.
Parameters
string $entity_type_id: Entity type id.
string $bundle: Bundle id.
Return value
array Array with statistics.
1 call to xmlsitemap_get_link_type_indexed_status()
- xmlsitemap_add_form_entity_summary in ./
xmlsitemap.module - Add a table summary for an entity and its bundles.
File
- ./
xmlsitemap.module, line 830 - xmlsitemap XML sitemap
Code
function xmlsitemap_get_link_type_indexed_status($entity_type_id, $bundle = '') {
$info = xmlsitemap_get_link_info($entity_type_id);
$database = \Drupal::database();
$entity_type = \Drupal::entityTypeManager()
->getDefinition($entity_type_id);
$status['indexed'] = $database
->query("SELECT COUNT(id) FROM {xmlsitemap} WHERE type = :entity AND subtype = :bundle", [
':entity' => $entity_type_id,
':bundle' => $bundle,
])
->fetchField();
$status['visible'] = $database
->query("SELECT COUNT(id) FROM {xmlsitemap} WHERE type = :entity AND subtype = :bundle AND status = 1 AND access = 1", [
':entity' => $entity_type_id,
':bundle' => $bundle,
])
->fetchField();
try {
$query = \Drupal::entityQuery($entity_type_id);
if ($bundle && $entity_type
->hasKey('bundle')) {
$query
->condition($entity_type
->getKey('bundle'), $bundle);
}
// We are only using this for totals, so we can skip the access check.
$query
->accessCheck(FALSE);
$query
->addTag('xmlsitemap_link_indexed_status');
$status['total'] = $query
->count()
->execute();
return $status;
} catch (\Exception $e) {
$status['total'] = 0;
}
return $status;
}