You are here

function NodeType::get_paths in Simple XML sitemap 8

Returns an array of all urls and their data of a bundle.

@abstract

Parameters

string $bundle: Machine name of the bundle, eg. 'page'.

Return value

array $paths A numeric array of Drupal internal path data sets containing the internal path, url objects for every language (optional), lastmod (optional) and priority (optional):

array( 0 => array( 'path_data' => array( 'path' => '/relative/path/to/drupal/page', 'urls' => array( //optional 'en' => Drupal\Core\Url, 'de' => Drupal\Core\Url, ), ), 'priority' => 0.5 // optional 'lastmod' => '1234567890' // optional: content changed unix date ), )

Overrides LinkGeneratorBase::get_paths

File

src/Plugin/LinkGenerator/NodeType.php, line 26
Contains \Drupal\simplesitemap\Plugin\LinkGenerator\NodeType.

Class

NodeType
NodeType class.

Namespace

Drupal\simplesitemap\Plugin\LinkGenerator

Code

function get_paths($bundle) {
  $results = db_query("SELECT nid, changed FROM {node_field_data} WHERE status = 1 AND type = :type", array(
    ':type' => $bundle,
  ))
    ->fetchAllAssoc('nid');
  $paths = array();
  foreach ($results as $id => $data) {
    $paths[$id]['path_data'] = $this
      ->get_multilang_urls_from_route("entity.node.canonical", array(
      'node' => $id,
    ));
    $paths[$id]['lastmod'] = $data->changed;
  }
  return $paths;
}