function xmlsitemap_is_entity_type_supported in XML sitemap 8
Same name and namespace in other branches
- 2.x xmlsitemap.module \xmlsitemap_is_entity_type_supported()
Determines if an entity type can be listed in the XML sitemap as links.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.
Return value
bool TRUE if the entity type can be used, or FALSE otherwise.
1 call to xmlsitemap_is_entity_type_supported()
- xmlsitemap_get_link_info in ./
xmlsitemap.module - Returns information about supported sitemap link types.
1 string reference to 'xmlsitemap_is_entity_type_supported'
- XmlSitemapEntitiesSettingsForm::buildForm in src/
Form/ XmlSitemapEntitiesSettingsForm.php - Form constructor.
File
- ./
xmlsitemap.module, line 657 - xmlsitemap XML sitemap
Code
function xmlsitemap_is_entity_type_supported(EntityTypeInterface $entity_type) {
// If the XML sitemap status in the entity type annotation has been set then
// return that first. This will allow modules to bypass the logic below if
// needed.
$status = $entity_type
->get('xmlsitemap');
if ($status !== NULL) {
return $status;
}
// Skip if the entity type is not a content entity type.
if (!$entity_type instanceof ContentEntityTypeInterface) {
return FALSE;
}
// Skip if the entity type is internal (and not considered public).
if ($entity_type
->isInternal()) {
return FALSE;
}
// Skip if the entity type does not have a canonical URL.
if (!$entity_type
->hasLinkTemplate('canonical') && !$entity_type
->getUriCallback()) {
return FALSE;
}
// Skip if the entity type as a bundle entity type but does not yet have
// any bundles created.
if ($entity_type
->getBundleEntityType() && !\Drupal::service('entity_type.bundle.info')
->getBundleInfo($entity_type
->id())) {
return FALSE;
}
return TRUE;
}