PathProcessorSitemapVariant.php 605 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace Drupal\simple_sitemap\PathProcessor;
  3. use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
  4. use Symfony\Component\HttpFoundation\Request;
  5. /**
  6. * Class PathProcessorSitemapVariant
  7. * @package Drupal\simple_sitemap\PathProcessor
  8. */
  9. class PathProcessorSitemapVariant implements InboundPathProcessorInterface {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function processInbound($path, Request $request) {
  14. $args = explode('/', $path);
  15. if (count($args) === 3 && $args[2] === 'sitemap.xml') {
  16. $path = '/sitemaps/' . $args[1] . '/sitemap.xml';
  17. }
  18. return $path;
  19. }
  20. }