You are here

function Menu::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/Menu.php, line 26
Contains \Drupal\simplesitemap\LinkGenerator\Menu.

Class

Menu
Menu class.

Namespace

Drupal\simplesitemap\Plugin\LinkGenerator

Code

function get_paths($bundle) {
  $routes = db_query("SELECT mlid, route_name, route_parameters, options FROM {menu_tree} WHERE menu_name = :menu_name and enabled = 1", array(
    ':menu_name' => $bundle,
  ))
    ->fetchAllAssoc('mlid');
  $paths = array();
  foreach ($routes as $id => $entity) {
    if (empty($entity->route_name)) {
      continue;
    }

    //todo: There may be a better way to do this.
    $options = !empty($options = unserialize($entity->options)) ? $options : array();
    $route_parameters = !empty($route_parameters = unserialize($entity->route_parameters)) ? array(
      key($route_parameters) => $route_parameters[key($route_parameters)],
    ) : array();
    $paths[$id]['path_data'] = $this
      ->get_multilang_urls_from_route($entity->route_name, $route_parameters, $options);

    //todo: Implement lastmod for menu items.
  }
  return $paths;
}