You are here

function xmlsitemap_views_data_alter in XML sitemap 8

Same name and namespace in other branches
  1. 2.x xmlsitemap.views.inc \xmlsitemap_views_data_alter()

Implements hook_views_data_alter().

File

./xmlsitemap.views.inc, line 72
Views integration for xmlsitemap.

Code

function xmlsitemap_views_data_alter(array &$data) {
  foreach (\Drupal::entityTypeManager()
    ->getDefinitions() as $id => $definition) {
    if (!xmlsitemap_link_entity_check_enabled($id) && !empty($data[$definition
      ->getBaseTable()])) {
      continue;
    }
    $data[$definition
      ->getBaseTable()]['xmlsitemap_settings'] = [
      'title' => t('XML Sitemap Settings'),
      'relationship' => [
        'id' => 'standard',
        'base' => 'xmlsitemap',
        'base field' => 'id',
        'field' => $definition
          ->getKey('id'),
        'label' => t('XML Sitemap Settings'),
        'extra' => [
          [
            'field' => 'type',
            'value' => $id,
          ],
        ],
      ],
    ];
  }
}