You are here

class SitemapPathProcessor in Simple XML sitemap 4.x

Class SitemapInboundPathProcessor

Hierarchy

Expanded class hierarchy of SitemapPathProcessor

1 string reference to 'SitemapPathProcessor'
simple_sitemap.services.yml in ./simple_sitemap.services.yml
simple_sitemap.services.yml
1 service uses SitemapPathProcessor
simple_sitemap.path_processor in ./simple_sitemap.services.yml
Drupal\simple_sitemap\PathProcessor\SitemapPathProcessor

File

src/PathProcessor/SitemapPathProcessor.php, line 13

Namespace

Drupal\simple_sitemap\PathProcessor
View source
class SitemapPathProcessor implements InboundPathProcessorInterface, OutboundPathProcessorInterface {

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

  /**
   * {@inheritdoc}
   */
  public function processOutbound($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleable_metadata = NULL) {
    $args = explode('/', $path);
    if (count($args) === 4 && $args[3] === 'sitemap.xml') {
      $path = '/' . $args[2] . '/sitemap.xml';
    }
    return $path;
  }

}

Members