public function ArgumentCollector::onTerminate in Simple XML sitemap (Views integration) 8
Collect information about views URLs.
Parameters
\Symfony\Component\HttpKernel\Event\PostResponseEvent $event: Object of event after a response was sent.
File
- src/
EventSubscriber/ ArgumentCollector.php, line 73 - Contains argument collector.
Class
- ArgumentCollector
- Collect information about views URLs.
Namespace
Drupal\simple_sitemap_views\EventSubscriberCode
public function onTerminate(PostResponseEvent $event) {
// Only successful requests are interesting.
if ($event
->getResponse()
->isSuccessful()) {
// Get view ID from route.
$view_id = $this->routeMatch
->getParameter('view_id');
/** @var \Drupal\views\ViewEntityInterface $view_entity */
if ($view_id && ($view_entity = $this->viewStorage
->load($view_id))) {
// Get display ID from route.
$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->simpleSitemapViews
->addArgumentsToIndex($view, $args, $display_id);
// Destroy a view instance.
$view
->destroy();
}
}
}