TaxonomyVocabulary.php 978 Bytes
Newer Older
1 2 3
<?php
/**
 * @file
4
 * Contains \Drupal\simplesitemap\LinkGenerator\TaxonomyVocabulary.
5 6 7 8
 *
 * Plugin for taxonomy term entity link generation.
 */

9
namespace Drupal\simplesitemap\Plugin\LinkGenerator;
10

11 12
use Drupal\simplesitemap\Annotation\LinkGenerator;
use Drupal\simplesitemap\LinkGeneratorBase;
13 14 15
use Drupal\Core\Url;

/**
16 17 18 19 20
 * TaxonomyVocabulary class.
 *
 * @LinkGenerator(
 *   id = "taxonomy_vocabulary"
 * )
21
 */
22
class TaxonomyVocabulary extends LinkGeneratorBase {
23

24 25 26
  /**
   * {@inheritdoc}
   */
27
  function get_entity_bundle_paths($bundle) {
28
    $results = db_query("SELECT tid, changed FROM {taxonomy_term_field_data} WHERE vid = :vid", array(':vid' => $bundle))
29
      ->fetchAllAssoc('tid');
30

31
    $paths = array();
32 33 34
    foreach ($results as $id => $data) {
        $paths[$id]['path'] = Url::fromRoute("entity.taxonomy_term.canonical", array('taxonomy_term' => $id), array())->getInternalPath();
      $paths[$id]['lastmod'] = $data->changed;
35
    }
36
    return $paths;
37 38
  }
}