I'm using OutboundPathProcessorInterface. I notice a few odd things about its behavior.

  1. In adding, for example, "/x" to the path, it works in some cases, like admin/structure, but not others, like admin/content or the path I'm interested in, which is defined in a view. This is despite my setting the module's weight to 999 in its install file (before installing), so presumably no other module would be altering the path downstream.
  2. Where it does work, such as admin/structure, the page with the original path loads, with the original URL in the address bar, but all menu links have the altered path.
  3. When I watch it in xdebug, AFTER I alter the path with the query string in $options the URL comes through the function again, with the path set to the original value.

1 Answer 1

  1. The module weight won't do anything here. You set the priority in the service tag.

  2. You have to look what other path processors do at which priority to find the right place for your custom code. And use an inbound path processor to remove the x you have added outbound.

  3. The outbound processor is called multiple times while building a page, because you usually have more than one link on the site (and not all are visible).

  4. (question in comments) You can do this, outbound transfer query parameters to the path and inbound transfer parts of the path again back to the query parameters. Internally Drupal sees only the short base path with query parameters, externally you see the full path without query parameters. An example for inbound is PathProcessorFiles::processInbound

  • I see that unlike 'weight', where a lower priority is used before a higher one, 'priority' uses the higher value first, and core uses 0. I need to manipulate the URL after whatever core functions are doing so. Also using 0 and hoping for the best in terms of where that puts me in the execution order won't work, since I think that's what not specifying a priority does. Do I use a negative value?
    – JAyenGreen
    Commented Jun 22, 2017 at 14:02
  • yes, when the core service uses 0 tag your service with a negative priority to run it later
    – 4uk4
    Commented Jun 22, 2017 at 14:24
  • After much battling with -1 up to -32766, and the address bar not changing, I noticed that the page's Next Page link does contain the amended url, the same behavior I noticed with admin/structure remaining so in the address bar, but the links on the page having admin/structure/x. What needs to happen for the amended link to appear in the address bar (presumably, which would indicate the request as well) so that SEO, bookmarks, etc. would pick up the amended URL from the initial page load and not just subsequent clicks?
    – JAyenGreen
    Commented Jun 22, 2017 at 17:20
  • this looks more like a redirect
    – 4uk4
    Commented Jun 22, 2017 at 17:42
  • It's not. The appended path parts are treated as extra information...the destination remains the same. Simply put, if the url starts off as my/topic?topic_name=drupal&topic_id=123, the URL should appear as my/topic/drupal. The issues in solving this are that 1. there is no way to change the generation of the initial URL, and 2. the possible terms are too numerous and dynamic to build into .htaccess, and path auto ignores query strings.
    – JAyenGreen
    Commented Jun 22, 2017 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.