I tried overwrite all links from my site in Drupal 8 in accordance with a URL parameter.
I use the service path_processor_outbound and implemented the processOutbound()
method, extending the OutboundPathProcessorInterface
interface.
services.yml
services:
test_concept.test_concept_sayHelloService:
class: Drupal\test_concept\Services\TestConceptRepeater
tags:
- { name: 'path_processor_inbound', priority: 100 }
- { name: 'path_processor_outbound', priority: 300 }
Method of my class
public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
$current_uri = \Drupal::request()->getRequestUri();
$path_args = explode('/', $current_uri);
$sede = $path_args[1];
$path = "/" . $sede . $path;
return $path;
}
This work very good when reloading the site alter flushing the cache, but when I change the URL parameter and reload the site again, the URLs don't change, even if processOutbound()
runs again.
Is a problem with the cache?