You are here

public function SimpleSitemapViews::getSitemapSettings in Simple XML sitemap (Views integration) 8

Get sitemap settings for view display.

Parameters

\Drupal\views\ViewExecutable $view: A view executable instance.

string|null $display_id: The display id. If empty uses the preselected display.

Return value

array|null The sitemap settings if the display is indexed, NULL otherwise.

2 calls to SimpleSitemapViews::getSitemapSettings()
SimpleSitemapViews::addArgumentsToIndex in src/SimpleSitemapViews.php
Adds view arguments to the index.
SimpleSitemapViews::getIndexableArguments in src/SimpleSitemapViews.php
Get indexable arguments for view display.

File

src/SimpleSitemapViews.php, line 56
Contains simple_sitemap_views service.

Class

SimpleSitemapViews
Class to manage sitemap data for views.

Namespace

Drupal\simple_sitemap_views

Code

public function getSitemapSettings(ViewExecutable $view, $display_id = NULL) {

  // Ensure the display was correctly set.
  if (!$view
    ->setDisplay($display_id)) {
    return NULL;
  }

  // Get the list of extenders.
  $extenders = $view->display_handler
    ->getExtenders();
  $extender = isset($extenders['simple_sitemap_display_extender']) ? $extenders['simple_sitemap_display_extender'] : NULL;

  // Retrieve the sitemap settings from the extender.
  if ($extender instanceof SimpleSitemapDisplayExtender && $extender
    ->hasSitemapSettings() && $extender
    ->isIndexingEnabled()) {
    return $extender
      ->getSitemapSettings();
  }
  return NULL;
}