public function ArgumentCollector::onTerminate in Simple XML sitemap 8.3
Same name and namespace in other branches
- 4.x modules/simple_sitemap_views/src/EventSubscriber/ArgumentCollector.php \Drupal\simple_sitemap_views\EventSubscriber\ArgumentCollector::onTerminate()
Collect information about views arguments.
Parameters
\Symfony\Component\HttpKernel\Event\PostResponseEvent $event: Object of event after a response was sent.
File
- modules/
simple_sitemap_views/ src/ EventSubscriber/ ArgumentCollector.php, line 68
Class
- ArgumentCollector
- Collect information about views arguments.
Namespace
Drupal\simple_sitemap_views\EventSubscriberCode
public function onTerminate(PostResponseEvent $event) {
// Only successful requests are interesting.
// Collect information about arguments only if views support is enabled.
if (!$event
->getResponse()
->isSuccessful() || !$this->sitemapViews
->isEnabled()) {
return;
}
$view_id = $this->routeMatch
->getParameter('view_id');
/** @var \Drupal\views\ViewEntityInterface $view_entity */
if ($view_id && ($view_entity = $this->viewStorage
->load($view_id))) {
$display_id = $this->routeMatch
->getParameter('display_id');
// Get a set of view arguments and try to add them to the index.
$view = $view_entity
->getExecutable();
$args = $this
->getViewArgumentsFromRoute();
$this->sitemapViews
->addArgumentsToIndex($view, $args, $display_id);
// Destroy a view instance.
$view
->destroy();
}
}