You are here

function xmlsitemap_entity_type_build in XML sitemap 2.x

Same name and namespace in other branches
  1. 8 xmlsitemap.module \xmlsitemap_entity_type_build()

Implements hook_entity_type_build().

File

./xmlsitemap.module, line 623
xmlsitemap XML sitemap

Code

function xmlsitemap_entity_type_build(array &$entity_types) {

  // Mark some specific core entity types as not supported by XML sitemap.
  // If a site wants to undo this, they may use hook_entity_type_alter().
  $unsupported_types = [
    // Custom blocks.
    'block_content',
    // Comments.
    'comment',
    // Shortcut items.
    'shortcut',
    // Redirects.
    'redirect',
    // Custom Token module.
    // @see https://www.drupal.org/project/token_custom/issues/3150038
    'token_custom',
  ];

  /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
  foreach ($unsupported_types as $entity_type_id) {
    if (isset($entity_types[$entity_type_id])) {
      $entity_types[$entity_type_id]
        ->set('xmlsitemap', FALSE);
    }
  }
}