PathProcessorTest.php

Same filename in this branch
  1. 11.x core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php
  2. 11.x core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
Same filename in other branches
  1. 9 core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php
  2. 9 core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
  3. 8.9.x core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php
  4. 8.9.x core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
  5. 10 core/modules/forum/tests/modules/forum_url_alter_test/src/PathProcessorTest.php
  6. 10 core/modules/system/tests/modules/url_alter_test/src/PathProcessorTest.php
  7. 10 core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php

Namespace

Drupal\forum_url_alter_test

File

core/modules/forum/tests/modules/forum_url_alter_test/src/PathProcessorTest.php

View source
<?php

namespace Drupal\forum_url_alter_test;

use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\HttpFoundation\Request;

/**
 * Path processor for url_alter_test.
 */
class PathProcessorTest implements InboundPathProcessorInterface, OutboundPathProcessorInterface {
    
    /**
     * {@inheritdoc}
     */
    public function processInbound($path, Request $request) {
        // Rewrite community/ to forum/.
        return preg_replace('@^/community(.*)@', '/forum$1', $path);
    }
    
    /**
     * {@inheritdoc}
     */
    public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
        // Rewrite forum/ to community/.
        return preg_replace('@^/forum(.*)@', '/community$1', $path);
    }

}

Classes

Title Deprecated Summary
PathProcessorTest Path processor for url_alter_test.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.