EntityLinkGenerator.php 1.04 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
/**
 * @file
 * Contains \Drupal\simplesitemap\LinkGenerators\EntityLinkGenerator.
 *
 * Abstract class to be extended for plugin creation.
 * See \Drupal\simplesitemap\LinkGenerators\CustomLinkGenerator\node for more
 * documentation.
 */

namespace Drupal\simplesitemap\LinkGenerators;
use Drupal\simplesitemap\SitemapGenerator;

/**
 * EntityLinkGenerator abstract class.
 */
abstract class EntityLinkGenerator {

  private $entity_links = array();

  public function get_entity_links($entity_type, $bundles, $language) {
    foreach($bundles as $bundle => $bundle_settings) {
      if (!$bundle_settings['index']) {
        continue;
      }
      $links = $this->get_entity_bundle_links($entity_type, $bundle, $language);

      foreach ($links as &$link) {
        $link = SitemapGenerator::add_xml_link_markup($link, $bundle_settings['priority']);
      }
31
      $this->entity_links = array_merge($this->entity_links, $links);
32
33
34
35
36
37
    }
    return $this->entity_links;
  }

  abstract function get_entity_bundle_links($entity_type, $bundle, $language);
}