PathProcessorSitemapVariant.php 605 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<?php

namespace Drupal\simple_sitemap\PathProcessor;

use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * Class PathProcessorSitemapVariant
 * @package Drupal\simple_sitemap\PathProcessor
 */
class PathProcessorSitemapVariant implements InboundPathProcessorInterface {

  /**
   * {@inheritdoc}
   */
  public function processInbound($path, Request $request) {
    $args = explode('/', $path);
19
    if (count($args) === 3 && $args[2] === 'sitemap.xml') {
20 21 22 23 24 25
      $path = '/sitemaps/' . $args[1] . '/sitemap.xml';
    }

    return $path;
  }
}